05b864f2d3b6fc43472ebd501ed1e29d0119a82f132c40aef7f60a98ee5606f201ccf4fc0c6f8733b962289beb92fc359dcde5a7dd88b91b7e6ab832294570 813 B

123456789101112131415161718192021222324
  1. const platform = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform;
  2. import { parse, resolve } from 'path';
  3. export const pathArg = (path) => {
  4. if (/\0/.test(path)) {
  5. // simulate same failure that node raises
  6. throw Object.assign(new TypeError('path must be a string without null bytes'), {
  7. path,
  8. code: 'ERR_INVALID_ARG_VALUE',
  9. });
  10. }
  11. path = resolve(path);
  12. if (platform === 'win32') {
  13. const badWinChars = /[*|"<>?:]/;
  14. const { root } = parse(path);
  15. if (badWinChars.test(path.substring(root.length))) {
  16. throw Object.assign(new Error('Illegal characters in path.'), {
  17. path,
  18. code: 'EINVAL',
  19. });
  20. }
  21. }
  22. return path;
  23. };
  24. //# sourceMappingURL=path-arg.js.map