@tapjs/processinfo 3.1.5 → 3.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/commonjs/canonical-source.d.ts +3 -0
  2. package/dist/commonjs/canonical-source.d.ts.map +1 -0
  3. package/dist/commonjs/canonical-source.js +38 -0
  4. package/dist/commonjs/canonical-source.js.map +1 -0
  5. package/dist/commonjs/child_process.js +9 -9
  6. package/dist/commonjs/child_process.js.map +1 -1
  7. package/dist/commonjs/get-process-info.js +1 -1
  8. package/dist/commonjs/get-process-info.js.map +1 -1
  9. package/dist/commonjs/node-options-env.d.ts +1 -1
  10. package/dist/commonjs/node-options-env.d.ts.map +1 -1
  11. package/dist/commonjs/node-options-env.js +80 -12
  12. package/dist/commonjs/node-options-env.js.map +1 -1
  13. package/dist/commonjs/register-coverage.d.ts.map +1 -1
  14. package/dist/commonjs/register-coverage.js +19 -4
  15. package/dist/commonjs/register-coverage.js.map +1 -1
  16. package/dist/commonjs/register-env.js +3 -3
  17. package/dist/commonjs/register-env.js.map +1 -1
  18. package/dist/commonjs/spawn-opts.d.ts +1 -1
  19. package/dist/commonjs/spawn-opts.d.ts.map +1 -1
  20. package/dist/commonjs/spawn-opts.js +8 -2
  21. package/dist/commonjs/spawn-opts.js.map +1 -1
  22. package/dist/esm/canonical-source.d.ts +3 -0
  23. package/dist/esm/canonical-source.d.ts.map +1 -0
  24. package/dist/esm/canonical-source.js +33 -0
  25. package/dist/esm/canonical-source.js.map +1 -0
  26. package/dist/esm/child_process.js +9 -9
  27. package/dist/esm/child_process.js.map +1 -1
  28. package/dist/esm/get-process-info.js +1 -1
  29. package/dist/esm/get-process-info.js.map +1 -1
  30. package/dist/esm/node-options-env.d.ts +1 -1
  31. package/dist/esm/node-options-env.d.ts.map +1 -1
  32. package/dist/esm/node-options-env.js +81 -13
  33. package/dist/esm/node-options-env.js.map +1 -1
  34. package/dist/esm/register-coverage.d.ts.map +1 -1
  35. package/dist/esm/register-coverage.js +19 -4
  36. package/dist/esm/register-coverage.js.map +1 -1
  37. package/dist/esm/register-env.js +3 -3
  38. package/dist/esm/register-env.js.map +1 -1
  39. package/dist/esm/spawn-opts.d.ts +1 -1
  40. package/dist/esm/spawn-opts.d.ts.map +1 -1
  41. package/dist/esm/spawn-opts.js +8 -2
  42. package/dist/esm/spawn-opts.js.map +1 -1
  43. package/package.json +1 -1
@@ -9,21 +9,21 @@ const node_options_env_js_1 = require("./node-options-env.js");
9
9
  const p = process;
10
10
  const envRE = /^_TAPJS_PROCESSINFO_/;
11
11
  const { hasOwnProperty } = Object.prototype;
12
- const getEnvs = (env) => {
12
+ const getEnvs = (env, args = []) => {
13
13
  // load it here so that it isn't cached before the loader attaches
14
14
  // in self-test scenario.
15
15
  // copy all of OUR envs, if not specifically set on the env object
16
16
  return Object.fromEntries(Object.entries(p.env)
17
17
  .filter(([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k))
18
18
  .concat([
19
- ['NODE_OPTIONS', (0, node_options_env_js_1.nodeOptionsEnv)(env?.NODE_OPTIONS ? env : p.env)],
19
+ ['NODE_OPTIONS', (0, node_options_env_js_1.nodeOptionsEnv)(env?.NODE_OPTIONS ? env : p.env, args)],
20
20
  ]));
21
21
  };
22
22
  const register = () => {
23
23
  process_on_spawn_1.default.addListener(obj => {
24
24
  obj.env = {
25
25
  ...(obj.env || p.env),
26
- ...getEnvs(obj.env),
26
+ ...getEnvs(obj.env, obj.args),
27
27
  };
28
28
  return obj;
29
29
  });
@@ -1 +1 @@
1
- {"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../src/register-env.ts"],"names":[],"mappings":";;;;;;AAAA,wEAA6C;AAC7C,+DAAsD;AAEtD,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE;IAC1C,kEAAkE;IAClE,yBAAyB;IACzB,kEAAkE;IAClE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;SAClB,MAAM,CACL,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAChE;SACA,MAAM,CAAC;QACN,CAAC,cAAc,EAAE,IAAA,oCAAc,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KAClE,CAAC,CACL,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,0BAAc,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,CAAC,GAAG,GAAG;YACR,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC;YACrB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;SACpB,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB","sourcesContent":["import processOnSpawn from 'process-on-spawn'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nconst p = process\nconst envRE = /^_TAPJS_PROCESSINFO_/\nconst { hasOwnProperty } = Object.prototype\n\nconst getEnvs = (env?: NodeJS.ProcessEnv) => {\n // load it here so that it isn't cached before the loader attaches\n // in self-test scenario.\n // copy all of OUR envs, if not specifically set on the env object\n return Object.fromEntries(\n Object.entries(p.env)\n .filter(\n ([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k)\n )\n .concat([\n ['NODE_OPTIONS', nodeOptionsEnv(env?.NODE_OPTIONS ? env : p.env)],\n ])\n )\n}\n\nexport const register = () => {\n processOnSpawn.addListener(obj => {\n obj.env = {\n ...(obj.env || p.env),\n ...getEnvs(obj.env),\n }\n return obj\n })\n}\n"]}
1
+ {"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../src/register-env.ts"],"names":[],"mappings":";;;;;;AAAA,wEAA6C;AAC7C,+DAAsD;AAEtD,MAAM,CAAC,GAAG,OAAO,CAAA;AACjB,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,OAA0B,EAAE,EAAE,EAAE;IACxE,kEAAkE;IAClE,yBAAyB;IACzB,kEAAkE;IAClE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;SAClB,MAAM,CACL,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAChE;SACA,MAAM,CAAC;QACN,CAAC,cAAc,EAAE,IAAA,oCAAc,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KACxE,CAAC,CACL,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,0BAAc,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,CAAC,GAAG,GAAG;YACR,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC;YACrB,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC;SAC9B,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB","sourcesContent":["import processOnSpawn from 'process-on-spawn'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nconst p = process\nconst envRE = /^_TAPJS_PROCESSINFO_/\nconst { hasOwnProperty } = Object.prototype\n\nconst getEnvs = (env?: NodeJS.ProcessEnv, args: readonly string[] = []) => {\n // load it here so that it isn't cached before the loader attaches\n // in self-test scenario.\n // copy all of OUR envs, if not specifically set on the env object\n return Object.fromEntries(\n Object.entries(p.env)\n .filter(\n ([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k)\n )\n .concat([\n ['NODE_OPTIONS', nodeOptionsEnv(env?.NODE_OPTIONS ? env : p.env, args)],\n ])\n )\n}\n\nexport const register = () => {\n processOnSpawn.addListener(obj => {\n obj.env = {\n ...(obj.env || p.env),\n ...getEnvs(obj.env, obj.args),\n }\n return obj\n })\n}\n"]}
@@ -4,7 +4,7 @@ export type WithExternalID<T> = T & {
4
4
  };
5
5
  export declare const spawnOpts: <T extends {
6
6
  [k: string]: any;
7
- }>(options: WithExternalID<T>, exclude?: RegExp | string) => Omit<T, "externalID"> & {
7
+ }>(options: WithExternalID<T>, exclude?: RegExp | string, args?: readonly string[]) => Omit<T, "externalID"> & {
8
8
  env: ProcessEnvOptions;
9
9
  };
10
10
  //# sourceMappingURL=spawn-opts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spawn-opts.d.ts","sourceRoot":"","sources":["../../src/spawn-opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGjD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAG3D,eAAO,MAAM,SAAS;;yCAEV,MAAM,GAAG,MAAM;SACO,iBAAiB;CAWlD,CAAA"}
1
+ {"version":3,"file":"spawn-opts.d.ts","sourceRoot":"","sources":["../../src/spawn-opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAGjD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAG3D,eAAO,MAAM,SAAS;;yCAEV,MAAM,GAAG,MAAM,SAClB,SAAS,MAAM,EAAE;SACQ,iBAAiB;CAiBlD,CAAA"}
@@ -3,10 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.spawnOpts = void 0;
4
4
  const node_options_env_js_1 = require("./node-options-env.js");
5
5
  const p = process;
6
- const spawnOpts = (options, exclude) => {
6
+ const spawnOpts = (options, exclude, args) => {
7
7
  const { externalID, ...rest } = options;
8
8
  const env = { ...(options.env || p.env) };
9
- env.NODE_OPTIONS = (0, node_options_env_js_1.nodeOptionsEnv)(env);
9
+ // only add if lacking in args, but this can come in multiple ways
10
+ const a = [
11
+ ...(options.execArgv ?? []),
12
+ ...(args ?? []),
13
+ ...(options.args ?? []),
14
+ ];
15
+ env.NODE_OPTIONS = (0, node_options_env_js_1.nodeOptionsEnv)(env, a);
10
16
  if (externalID) {
11
17
  env._TAPJS_PROCESSINFO_EXTERNAL_ID_ = externalID;
12
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"spawn-opts.js","sourceRoot":"","sources":["../../src/spawn-opts.ts"],"names":[],"mappings":";;;AACA,+DAAsD;AAGtD,MAAM,CAAC,GAAG,OAAO,CAAA;AAEV,MAAM,SAAS,GAAG,CACvB,OAA0B,EAC1B,OAAyB,EAC2B,EAAE;IACtD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IACvC,MAAM,GAAG,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;IACzC,GAAG,CAAC,YAAY,GAAG,IAAA,oCAAc,EAAC,GAAG,CAAC,CAAA;IACtC,IAAI,UAAU,EAAE;QACd,GAAG,CAAC,+BAA+B,GAAG,UAAU,CAAA;KACjD;IACD,IAAI,OAAO,EAAE;QACX,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;KAClD;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,CAAA;AACzB,CAAC,CAAA;AAdY,QAAA,SAAS,aAcrB","sourcesContent":["import { ProcessEnvOptions } from 'child_process'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nexport type WithExternalID<T> = T & { externalID?: string }\nconst p = process\n\nexport const spawnOpts = <T extends { [k: string]: any }>(\n options: WithExternalID<T>,\n exclude?: RegExp | string\n): Omit<T, 'externalID'> & { env: ProcessEnvOptions } => {\n const { externalID, ...rest } = options\n const env = { ...(options.env || p.env) }\n env.NODE_OPTIONS = nodeOptionsEnv(env)\n if (externalID) {\n env._TAPJS_PROCESSINFO_EXTERNAL_ID_ = externalID\n }\n if (exclude) {\n env._TAPJS_PROCESSINFO_EXCLUDE_ = String(exclude)\n }\n return { ...rest, env }\n}\n"]}
1
+ {"version":3,"file":"spawn-opts.js","sourceRoot":"","sources":["../../src/spawn-opts.ts"],"names":[],"mappings":";;;AACA,+DAAsD;AAGtD,MAAM,CAAC,GAAG,OAAO,CAAA;AAEV,MAAM,SAAS,GAAG,CACvB,OAA0B,EAC1B,OAAyB,EACzB,IAAwB,EAC4B,EAAE;IACtD,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IACvC,MAAM,GAAG,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAA;IACzC,kEAAkE;IAClE,MAAM,CAAC,GAAG;QACR,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;QAC3B,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;KACxB,CAAA;IACD,GAAG,CAAC,YAAY,GAAG,IAAA,oCAAc,EAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IACzC,IAAI,UAAU,EAAE;QACd,GAAG,CAAC,+BAA+B,GAAG,UAAU,CAAA;KACjD;IACD,IAAI,OAAO,EAAE;QACX,GAAG,CAAC,2BAA2B,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA;KAClD;IACD,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,CAAA;AACzB,CAAC,CAAA;AArBY,QAAA,SAAS,aAqBrB","sourcesContent":["import { ProcessEnvOptions } from 'child_process'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nexport type WithExternalID<T> = T & { externalID?: string }\nconst p = process\n\nexport const spawnOpts = <T extends { [k: string]: any }>(\n options: WithExternalID<T>,\n exclude?: RegExp | string,\n args?: readonly string[]\n): Omit<T, 'externalID'> & { env: ProcessEnvOptions } => {\n const { externalID, ...rest } = options\n const env = { ...(options.env || p.env) }\n // only add if lacking in args, but this can come in multiple ways\n const a = [\n ...(options.execArgv ?? []),\n ...(args ?? []),\n ...(options.args ?? []),\n ]\n env.NODE_OPTIONS = nodeOptionsEnv(env, a)\n if (externalID) {\n env._TAPJS_PROCESSINFO_EXTERNAL_ID_ = externalID\n }\n if (exclude) {\n env._TAPJS_PROCESSINFO_EXCLUDE_ = String(exclude)\n }\n return { ...rest, env }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const canonicalSource: (s: string) => string;
2
+ export declare const canonicalPath: (s: string) => string;
3
+ //# sourceMappingURL=canonical-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-source.d.ts","sourceRoot":"","sources":["../../src/canonical-source.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,eAAe,MAAO,MAAM,KAAG,MAY3C,CAAA;AAED,eAAO,MAAM,aAAa,MAAO,MAAM,KAAG,MAUzC,CAAA"}
@@ -0,0 +1,33 @@
1
+ // The sources reported in sourcemaps can be fickle,
2
+ // and istanbul's reporting doesn't handle it so well.
3
+ // So, we canonicalize all entries in sources to a file://
4
+ // url with consistent capitalization.
5
+ import { relative, resolve } from 'path';
6
+ import { fileURLToPath, pathToFileURL } from 'url';
7
+ const cwd = process.cwd();
8
+ export const canonicalSource = (s) => {
9
+ // convert to a path
10
+ if (s.startsWith('file://')) {
11
+ const u = new URL(s);
12
+ const hash = u.hash;
13
+ const search = u.search;
14
+ return String(pathToFileURL(canonicalPath(fileURLToPath(s)))) +
15
+ hash + search;
16
+ }
17
+ // re-resolve it relative to the cwd
18
+ // back to a file: url
19
+ return String(pathToFileURL(canonicalPath(s)));
20
+ };
21
+ export const canonicalPath = (s) => {
22
+ const rel = relative(cwd, s);
23
+ s = resolve(cwd, rel);
24
+ // capitalize drive letters
25
+ if (/^[a-z]:/.test(s))
26
+ s = s.charAt(0).toUpperCase() + s.substring(1);
27
+ // capitalize UNC paths
28
+ if (s.startsWith('\\\\')) {
29
+ s = s.replace(/\\\\[^\\]+\\[^\\]+\\/, _0 => _0.toUpperCase());
30
+ }
31
+ return s;
32
+ };
33
+ //# sourceMappingURL=canonical-source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-source.js","sourceRoot":"","sources":["../../src/canonical-source.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,sDAAsD;AACtD,0DAA0D;AAC1D,sCAAsC;AAEtC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAClD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAS,EAAU,EAAE;IACnD,oBAAoB;IACpB,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC3B,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAA;QACnB,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAA;QACvB,OAAO,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,IAAI,GAAG,MAAM,CAAA;KAChB;IACD,oCAAoC;IACpC,sBAAsB;IACtB,OAAO,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAS,EAAU,EAAE;IACjD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC5B,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACrB,2BAA2B;IAC3B,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACrE,uBAAuB;IACvB,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;QACxB,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,CAAA;KAC9D;IACD,OAAO,CAAC,CAAA;AACV,CAAC,CAAA","sourcesContent":["// The sources reported in sourcemaps can be fickle,\n// and istanbul's reporting doesn't handle it so well.\n// So, we canonicalize all entries in sources to a file://\n// url with consistent capitalization.\n\nimport { relative, resolve } from 'path'\nimport { fileURLToPath, pathToFileURL } from 'url'\nconst cwd = process.cwd()\n\nexport const canonicalSource = (s: string): string => {\n // convert to a path\n if (s.startsWith('file://')) {\n const u = new URL(s)\n const hash = u.hash\n const search = u.search\n return String(pathToFileURL(canonicalPath(fileURLToPath(s)))) +\n hash + search\n }\n // re-resolve it relative to the cwd\n // back to a file: url\n return String(pathToFileURL(canonicalPath(s)))\n}\n\nexport const canonicalPath = (s: string): string => {\n const rel = relative(cwd, s)\n s = resolve(cwd, rel)\n // capitalize drive letters\n if (/^[a-z]:/.test(s)) s = s.charAt(0).toUpperCase() + s.substring(1)\n // capitalize UNC paths\n if (s.startsWith('\\\\\\\\')) {\n s = s.replace(/\\\\\\\\[^\\\\]+\\\\[^\\\\]+\\\\/, _0 => _0.toUpperCase())\n }\n return s\n}\n"]}
@@ -17,24 +17,24 @@ export function spawn(cmd, args, options) {
17
17
  options = args;
18
18
  args = [];
19
19
  }
20
- return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k)));
20
+ return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k), args));
21
21
  }
22
22
  export function spawnSync(cmd, args, options) {
23
23
  if (isNotArray(args)) {
24
24
  options = args;
25
25
  args = [];
26
26
  }
27
- return cpSpawnSync(cmd, args || [], spawnOpts(options || {}, getExclude(k)));
27
+ return cpSpawnSync(cmd, args || [], spawnOpts(options || {}, getExclude(k), args));
28
28
  }
29
29
  export function exec(...args) {
30
30
  const [cmd, options, callback] = args;
31
31
  if (typeof options === 'function') {
32
- return cpExec(cmd, spawnOpts({}, getExclude(k)), options);
32
+ return cpExec(cmd, spawnOpts({}, getExclude(k), []), options);
33
33
  }
34
34
  else if (!options) {
35
- return cpExec(cmd, spawnOpts({}, getExclude(k)), callback);
35
+ return cpExec(cmd, spawnOpts({}, getExclude(k), []), callback);
36
36
  }
37
- return cpExec(cmd, spawnOpts(options, getExclude(k)), callback);
37
+ return cpExec(cmd, spawnOpts(options, getExclude(k), []), callback);
38
38
  }
39
39
  (function (exec) {
40
40
  function __promisify__(command, options) {
@@ -64,7 +64,7 @@ export function execFile(file, ...execFileArgs) {
64
64
  callback = arg;
65
65
  }
66
66
  }
67
- return cpExecFile(file, args, spawnOpts(options, getExclude(k)), callback);
67
+ return cpExecFile(file, args, spawnOpts(options, getExclude(k), args), callback);
68
68
  }
69
69
  (function (execFile) {
70
70
  function __promisify__(file, args, options) {
@@ -74,7 +74,7 @@ export function execFile(file, ...execFileArgs) {
74
74
  options = args;
75
75
  args = [];
76
76
  }
77
- return customPromisify(cpExecFile)(file, spawnOpts(options || {}, getExclude(k)));
77
+ return customPromisify(cpExecFile)(file, spawnOpts(options || {}, getExclude(k), args));
78
78
  }
79
79
  execFile.__promisify__ = __promisify__;
80
80
  Object.assign(execFile, { [promisify]: __promisify__ });
@@ -87,13 +87,13 @@ export function execFileSync(file, args, options) {
87
87
  options = args;
88
88
  args = [];
89
89
  }
90
- return cpExecFileSync(file, args || [], spawnOpts(options || {}, getExclude(k)));
90
+ return cpExecFileSync(file, args || [], spawnOpts(options || {}, getExclude(k), args));
91
91
  }
92
92
  export function fork(modulePath, args, options) {
93
93
  if (isNotArray(args)) {
94
94
  options = args;
95
95
  args = [];
96
96
  }
97
- return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k)));
97
+ return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k), args));
98
98
  }
99
99
  //# sourceMappingURL=child_process.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"child_process.js","sourceRoot":"","sources":["../../src/child_process.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,OAAO,EAIL,IAAI,IAAI,MAAM,EAEd,QAAQ,IAAI,UAAU,EAMtB,YAAY,IAAI,cAAc,EAK9B,QAAQ,IAAI,UAAU,EAItB,IAAI,IAAI,MAAM,EAGd,KAAK,IAAI,OAAO,EAIhB,SAAS,IAAI,WAAW,GAOzB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAA;AAE3D,MAAM,SAAS,G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AAC,CAAC,CACxC,CAAA;AACH,CAAC;AAWD,MAAM,UAAU,IAAI,CAClB,UAAkB,EAClB,IAA0C,EAC1C,OAAqC;IAErC,IAAI,UAAU,CAAc,IAAI,CAAC,EAAE;QACjC,OAAO,GAAG,IAAI,CAAA;QACd,IAAI,GAAG,EAAE,CAAA;KACV;IACD,OAAO,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC","sourcesContent":["// This wraps all of the various spawn methods such that externalID can be\n// set in the options, and ensuring that the proper envs get set.\nimport {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n exec as cpExec,\n ExecException,\n execFile as cpExecFile,\n ExecFileException,\n ExecFileOptions,\n ExecFileOptionsWithBufferEncoding,\n ExecFileOptionsWithOtherEncoding,\n ExecFileOptionsWithStringEncoding,\n execFileSync as cpExecFileSync,\n ExecFileSyncOptions,\n ExecFileSyncOptionsWithBufferEncoding,\n ExecFileSyncOptionsWithStringEncoding,\n ExecOptions,\n execSync as cpExecSync,\n ExecSyncOptions,\n ExecSyncOptionsWithBufferEncoding,\n ExecSyncOptionsWithStringEncoding,\n fork as cpFork,\n ForkOptions,\n PromiseWithChild,\n spawn as cpSpawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n spawnSync as cpSpawnSync,\n SpawnSyncOptions,\n SpawnSyncOptionsWithBufferEncoding,\n SpawnSyncOptionsWithStringEncoding,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'child_process'\nimport type { ObjectEncodingOptions } from 'fs'\nimport type { Readable, Writable } from 'stream'\nimport { getExclude } from './get-exclude.js'\nimport { spawnOpts, WithExternalID } from './spawn-opts.js'\n\nconst promisify = Symbol.for('nodejs.util.promisify.custom')\n\n// pull the old __promisify__ out of node's declared namespaces\ntype CP<T extends { __promisify__: any }> = T & {\n [promisify]: T['__promisify__']\n}\ntype OldCP = { __promisify__: (...a: any) => any }\nconst customPromisify = <T extends OldCP>(e: T) =>\n // the node types list it as __promisify__ but it's actually the symbol\n /* c8 ignore start */\n (e as CP<T>)[promisify] || e.__promisify__\n/* c8 ignore stop */\n\nconst k = '_TAPJS_PROCESSINFO_EXCLUDE_'\n\n// coercion function when we know it's an array or something else\nconst isNotArray = <T extends { [k: string]: any }>(o: any): o is T =>\n !!o && typeof o === 'object' && !Array.isArray(o)\n\nexport function spawn(\n command: string,\n options?: WithExternalID<SpawnOptionsWithoutStdio>\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<SpawnOptions>\n): ChildProcess\nexport function spawn(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnOptionsWithoutStdio\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptions\n): ChildProcess\n\nexport function spawn(\n cmd: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >,\n options?:\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >\n): ChildProcess | ChildProcessWithoutNullStreams {\n if (isNotArray<SpawnOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k)))\n}\n\nexport function spawnSync(command: string): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\n\nexport function spawnSync(\n cmd: string,\n args?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n | ReadonlyArray<string>,\n options?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n) {\n if (isNotArray<SpawnSyncOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawnSync(\n cmd,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport type ExecArgs =\n | [\n command: string,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<ExecOptions>,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | undefined\n | null,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\nexport function exec(...args: ExecArgs): ChildProcess {\n const [cmd, options, callback] = args\n if (typeof options === 'function') {\n return cpExec(cmd, spawnOpts<ExecOptions>({}, getExclude(k)), options)\n } else if (!options) {\n return cpExec(\n cmd,\n spawnOpts<ExecOptions>({}, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n }\n\n return cpExec(\n cmd,\n spawnOpts(options, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n}\n\nexport namespace exec {\n export function __promisify__(command: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<ExecOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options?: WithExternalID<ObjectEncodingOptions & ExecOptions> | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n command: string,\n options?:\n | WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n | WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n | WithExternalID<ExecOptions>\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n return customPromisify(cpExec)(\n command,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n\n Object.assign(exec, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execSync(command: string): Buffer\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithStringEncoding>\n): string\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execSync(\n command: string,\n options?: WithExternalID<ExecSyncOptions>\n): string | Buffer\nexport function execSync(\n cmd: string,\n options?:\n | WithExternalID<ExecSyncOptions>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n | WithExternalID<ExecSyncOptionsWithStringEncoding>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): string | Buffer {\n return cpExecSync(\n cmd,\n spawnOpts<ExecSyncOptions>(options || {}, getExclude(k))\n )\n}\n\nexport type ExecFileArgs =\n | []\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [args?: ReadonlyArray<string> | null]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\nexport function execFile(\n file: string,\n ...execFileArgs: ExecFileArgs\n): ChildProcess {\n let args = []\n let options: WithExternalID<ObjectEncodingOptions & ExecFileOptions> = {}\n let callback: ((...a: any) => any) | undefined = undefined\n for (const arg of execFileArgs) {\n if (Array.isArray(arg)) {\n args = arg\n } else if (\n arg &&\n typeof arg === 'object' &&\n isNotArray<WithExternalID<ObjectEncodingOptions & ExecFileOptions>>(\n arg\n )\n ) {\n options = arg\n } else if (typeof arg === 'function') {\n callback = arg\n }\n }\n return cpExecFile(\n file,\n args,\n spawnOpts(options, getExclude(k)),\n callback\n )\n}\n\nexport namespace execFile {\n export function __promisify__(file: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args?:\n | ReadonlyArray<string>\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>,\n options?:\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n if (\n !!args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n >(args)\n ) {\n options = args\n args = []\n }\n return customPromisify(cpExecFile)(\n file,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n Object.assign(execFile, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execFileSync(file: string): Buffer\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>\n): Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>,\n options?:\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): string | Buffer {\n if (\n args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n >(args)\n ) {\n options = args\n args = []\n }\n return cpExecFileSync(\n file,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport function fork(\n modulePath: string,\n options?: ForkOptions\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ForkOptions | ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess {\n if (isNotArray<ForkOptions>(args)) {\n options = args\n args = []\n }\n return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k)))\n}\n"]}
1
+ {"version":3,"file":"child_process.js","sourceRoot":"","sources":["../../src/child_process.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,OAAO,EAIL,IAAI,IAAI,MAAM,EAEd,QAAQ,IAAI,UAAU,EAMtB,YAAY,IAAI,cAAc,EAK9B,QAAQ,IAAI,UAAU,EAItB,IAAI,IAAI,MAAM,EAGd,KAAK,IAAI,OAAO,EAIhB,SAAS,IAAI,WAAW,GAOzB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAkB,MAAM,iBAAiB,CAAA;AAE3D,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;AAO5D,MAAM,eAAe,GAAG,CAAkB,CAAI,EAAE,EAAE;AAChD,uEAAuE;AACvE,qBAAqB;AACpB,CAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,CAAA;AAC5C,oBAAoB;AAEpB,MAAM,CAAC,GAAG,6BAA6B,CAAA;AAEvC,iEAAiE;AACjE,MAAM,UAAU,GAAG,CAAiC,CAAM,EAAU,EAAE,CACpE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IA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AO,IAAI,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;AAChF,CAAC","sourcesContent":["// This wraps all of the various spawn methods such that externalID can be\n// set in the options, and ensuring that the proper envs get set.\nimport {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n exec as cpExec,\n ExecException,\n execFile as cpExecFile,\n ExecFileException,\n ExecFileOptions,\n ExecFileOptionsWithBufferEncoding,\n ExecFileOptionsWithOtherEncoding,\n ExecFileOptionsWithStringEncoding,\n execFileSync as cpExecFileSync,\n ExecFileSyncOptions,\n ExecFileSyncOptionsWithBufferEncoding,\n ExecFileSyncOptionsWithStringEncoding,\n ExecOptions,\n execSync as cpExecSync,\n ExecSyncOptions,\n ExecSyncOptionsWithBufferEncoding,\n ExecSyncOptionsWithStringEncoding,\n fork as cpFork,\n ForkOptions,\n PromiseWithChild,\n spawn as cpSpawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n spawnSync as cpSpawnSync,\n SpawnSyncOptions,\n SpawnSyncOptionsWithBufferEncoding,\n SpawnSyncOptionsWithStringEncoding,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'child_process'\nimport type { ObjectEncodingOptions } from 'fs'\nimport type { Readable, Writable } from 'stream'\nimport { getExclude } from './get-exclude.js'\nimport { spawnOpts, WithExternalID } from './spawn-opts.js'\n\nconst promisify = Symbol.for('nodejs.util.promisify.custom')\n\n// pull the old __promisify__ out of node's declared namespaces\ntype CP<T extends { __promisify__: any }> = T & {\n [promisify]: T['__promisify__']\n}\ntype OldCP = { __promisify__: (...a: any) => any }\nconst customPromisify = <T extends OldCP>(e: T) =>\n // the node types list it as __promisify__ but it's actually the symbol\n /* c8 ignore start */\n (e as CP<T>)[promisify] || e.__promisify__\n/* c8 ignore stop */\n\nconst k = '_TAPJS_PROCESSINFO_EXCLUDE_'\n\n// coercion function when we know it's an array or something else\nconst isNotArray = <T extends { [k: string]: any }>(o: any): o is T =>\n !!o && typeof o === 'object' && !Array.isArray(o)\n\nexport function spawn(\n command: string,\n options?: WithExternalID<SpawnOptionsWithoutStdio>\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<SpawnOptions>\n): ChildProcess\nexport function spawn(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnOptionsWithoutStdio\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptions\n): ChildProcess\n\nexport function spawn(\n cmd: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >,\n options?:\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >\n): ChildProcess | ChildProcessWithoutNullStreams {\n if (isNotArray<SpawnOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k), args))\n}\n\nexport function spawnSync(command: string): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\n\nexport function spawnSync(\n cmd: string,\n args?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n | ReadonlyArray<string>,\n options?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n) {\n if (isNotArray<SpawnSyncOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawnSync(\n cmd,\n args || [],\n spawnOpts(options || {}, getExclude(k), args)\n )\n}\n\nexport type ExecArgs =\n | [\n command: string,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<ExecOptions>,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | undefined\n | null,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\nexport function exec(...args: ExecArgs): ChildProcess {\n const [cmd, options, callback] = args\n if (typeof options === 'function') {\n return cpExec(cmd, spawnOpts<ExecOptions>({}, getExclude(k), []), options)\n } else if (!options) {\n return cpExec(\n cmd,\n spawnOpts<ExecOptions>({}, getExclude(k), []),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n }\n\n return cpExec(\n cmd,\n spawnOpts(options, getExclude(k), []),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n}\n\nexport namespace exec {\n export function __promisify__(command: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<ExecOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options?: WithExternalID<ObjectEncodingOptions & ExecOptions> | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n command: string,\n options?:\n | WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n | WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n | WithExternalID<ExecOptions>\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n return customPromisify(cpExec)(\n command,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n\n Object.assign(exec, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execSync(command: string): Buffer\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithStringEncoding>\n): string\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execSync(\n command: string,\n options?: WithExternalID<ExecSyncOptions>\n): string | Buffer\nexport function execSync(\n cmd: string,\n options?:\n | WithExternalID<ExecSyncOptions>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n | WithExternalID<ExecSyncOptionsWithStringEncoding>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): string | Buffer {\n return cpExecSync(\n cmd,\n spawnOpts<ExecSyncOptions>(options || {}, getExclude(k))\n )\n}\n\nexport type ExecFileArgs =\n | []\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [args?: ReadonlyArray<string> | null]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\nexport function execFile(\n file: string,\n ...execFileArgs: ExecFileArgs\n): ChildProcess {\n let args = []\n let options: WithExternalID<ObjectEncodingOptions & ExecFileOptions> = {}\n let callback: ((...a: any) => any) | undefined = undefined\n for (const arg of execFileArgs) {\n if (Array.isArray(arg)) {\n args = arg\n } else if (\n arg &&\n typeof arg === 'object' &&\n isNotArray<WithExternalID<ObjectEncodingOptions & ExecFileOptions>>(\n arg\n )\n ) {\n options = arg\n } else if (typeof arg === 'function') {\n callback = arg\n }\n }\n return cpExecFile(\n file,\n args,\n spawnOpts(options, getExclude(k), args),\n callback\n )\n}\n\nexport namespace execFile {\n export function __promisify__(file: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args?:\n | ReadonlyArray<string>\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>,\n options?:\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n if (\n !!args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n >(args)\n ) {\n options = args\n args = []\n }\n return customPromisify(cpExecFile)(\n file,\n spawnOpts(options || {}, getExclude(k), args as readonly string[])\n )\n }\n Object.assign(execFile, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execFileSync(file: string): Buffer\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>\n): Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>,\n options?:\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): string | Buffer {\n if (\n args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n >(args)\n ) {\n options = args\n args = []\n }\n return cpExecFileSync(\n file,\n args || [],\n spawnOpts(options || {}, getExclude(k), args)\n )\n}\n\nexport function fork(\n modulePath: string,\n options?: ForkOptions\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ForkOptions | ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess {\n if (isNotArray<ForkOptions>(args)) {\n options = args\n args = []\n }\n return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k), args))\n}\n"]}
@@ -11,7 +11,7 @@ import { register as registerCoverage } from './register-coverage.js';
11
11
  import { register as registerEnv } from './register-env.js';
12
12
  import { register as registerProcessEnd } from './register-process-end.js';
13
13
  import { register as registerRequire } from './register-require.js';
14
- // this module is hybridized. In node v20.0 = v20.6, it's the *commonjs* one
14
+ // this module is hybridized. In node v20.0 - v20.6, it's the *commonjs* one
15
15
  // that gets loaded, because the esm loader context can't modify the main
16
16
  // thread except via communication over the port to the globalPreload env. So,
17
17
  // we have to store our singleton on the global.
@@ -1 +1 @@
1
- {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../src/get-process-info.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAGT,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,GAAG,CAAA;AACtE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9C,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/D,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO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EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI;QAChC,IAAI,EAAE,IAAI,EAAE;QACZ,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;KAC7B,CAAA;IAED,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;QAC3B,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAA;QAC3C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;KACrC;SAAM;QACL,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACtC;IACD,oDAAoD;IACpD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,kDAAkD;IAClD,iEAAiE;IACjE,sCAAsC;IACtC,qBAAqB;IACrB,IACE,OAAO,CAAC,GAAG,CAAC,yCAAyC;QACrD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EACnB;QACA,eAAe,EAAE,CAAA;QACjB,WAAW,EAAE,CAAA;QACb,gBAAgB,EAAE,CAAA;QAClB,kBAAkB,EAAE,CAAA;KACrB;IACD,oBAAoB;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n _eval?: string\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nimport { getMain } from './get-main.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => p.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (p.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete p.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerRequire } from './register-require.js'\n\n// this module is hybridized. In node v20.0 = v20.6, it's the *commonjs* one\n// that gets loaded, because the esm loader context can't modify the main\n// thread except via communication over the port to the globalPreload env. So,\n// we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n//\n// CJS registration can be removed once node < 20.6 is no longer supported.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: p.hrtime(),\n date: new Date().toISOString(),\n argv: p.argv,\n execArgv: p.execArgv,\n NODE_OPTIONS: p.env.NODE_OPTIONS,\n cwd: p.cwd(),\n pid: p.pid,\n ppid: p.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [getMain()],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n // switch to turn off registration for some tests.\n // excluded from coverage because that's the reason why it's here\n // in the first place, it confuses c8.\n /* c8 ignore start */\n if (\n process.env.__TAPJS_PROCESSINFO_TESTING_NO_REGISTER__ !==\n String(process.pid)\n ) {\n registerRequire()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n }\n /* c8 ignore stop */\n\n return g[kProcessInfo]\n}\n"]}
1
+ {"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../src/get-process-info.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAGT,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,GAAG,CAAA;AACtE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9C,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AAC/D,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AAErD,OAAO,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,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AE;QAC3B,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAA;QAC3C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;KACrC;SAAM;QACL,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACtC;IACD,oDAAoD;IACpD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,kDAAkD;IAClD,iEAAiE;IACjE,sCAAsC;IACtC,qBAAqB;IACrB,IACE,OAAO,CAAC,GAAG,CAAC,yCAAyC;QACrD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EACnB;QACA,eAAe,EAAE,CAAA;QACjB,WAAW,EAAE,CAAA;QACb,gBAAgB,EAAE,CAAA;QAClB,kBAAkB,EAAE,CAAA;KACrB;IACD,oBAAoB;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n _eval?: string\n}\np.setSourceMapsEnabled(true)\n\nimport { v4 as uuid } from 'uuid'\nimport { getMain } from './get-main.js'\nimport { ProcessInfoNodeData } from './process-info-node.js'\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => p.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (p.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete p.env[envKey(k)]\n\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\nimport { register as registerRequire } from './register-require.js'\n\n// this module is hybridized. In node v20.0 - v20.6, it's the *commonjs* one\n// that gets loaded, because the esm loader context can't modify the main\n// thread except via communication over the port to the globalPreload env. So,\n// we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n//\n// CJS registration can be removed once node < 20.6 is no longer supported.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n g[kProcessInfo] = {\n hrstart: p.hrtime(),\n date: new Date().toISOString(),\n argv: p.argv,\n execArgv: p.execArgv,\n NODE_OPTIONS: p.env.NODE_OPTIONS,\n cwd: p.cwd(),\n pid: p.pid,\n ppid: p.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [getMain()],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n // switch to turn off registration for some tests.\n // excluded from coverage because that's the reason why it's here\n // in the first place, it confuses c8.\n /* c8 ignore start */\n if (\n process.env.__TAPJS_PROCESSINFO_TESTING_NO_REGISTER__ !==\n String(process.pid)\n ) {\n registerRequire()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n }\n /* c8 ignore stop */\n\n return g[kProcessInfo]\n}\n"]}
@@ -2,5 +2,5 @@
2
2
  /// <reference types="node" resolution-mode="require"/>
3
3
  /// <reference types="node" resolution-mode="require"/>
4
4
  /// <reference types="node" resolution-mode="require"/>
5
- export declare const nodeOptionsEnv: (env: NodeJS.ProcessEnv) => string;
5
+ export declare const nodeOptionsEnv: (env: NodeJS.ProcessEnv, args: readonly string[]) => string;
6
6
  //# sourceMappingURL=node-options-env.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-options-env.d.ts","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":";;;;AAiGA,eAAO,MAAM,cAAc,QAAS,OAAO,UAAU,WAGpD,CAAA"}
1
+ {"version":3,"file":"node-options-env.d.ts","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":";;;;AAoKA,eAAO,MAAM,cAAc,QACpB,OAAO,UAAU,QAChB,SAAS,MAAM,EAAE,WAKxB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { argvToNodeOptions } from './argv-to-node-options.js';
2
- import { legacyLoader, legacyMatch, importLoader, importMatch, } from './loader-paths.js';
2
+ import { importLoader, importMatch, legacyLoader, legacyMatch, } from './loader-paths.js';
3
3
  import { nodeOptionsToArgv } from './node-options-to-argv.js';
4
4
  import Module from 'node:module';
5
5
  const getKeyValue = (args, i) => {
@@ -21,6 +21,73 @@ const getKeyValue = (args, i) => {
21
21
  };
22
22
  const useImport = !!Module
23
23
  .register;
24
+ // JUST test if we need to do anything at all with the env.
25
+ // if the loader is set already in the args, even incorrectly, return true
26
+ const hasLoader = (args) => {
27
+ for (let i = 0; i < args.length; i++) {
28
+ const arg = args[i];
29
+ /* c8 ignore start */
30
+ if (typeof arg !== 'string')
31
+ throw new Error('invalid arg');
32
+ /* c8 ignore stop */
33
+ if (!arg.startsWith('--') || arg === '--')
34
+ break;
35
+ const [eq, k, v] = getKeyValue(args, i);
36
+ if (!v) {
37
+ // wasn't a key-value pair
38
+ continue;
39
+ }
40
+ if (!eq)
41
+ i++;
42
+ if ((k === '--experimental-loader' || k === '--loader') &&
43
+ legacyMatch(v)) {
44
+ return true;
45
+ }
46
+ if (k === '--import' && importMatch(v))
47
+ return true;
48
+ }
49
+ return false;
50
+ };
51
+ const rmLoader = (args) => {
52
+ const doNotWantKeys = ['--experimental-loader', '--loader', '--import'];
53
+ const result = [];
54
+ let doubledash = false;
55
+ for (let i = 0; i < args.length; i++) {
56
+ const arg = args[i];
57
+ /* c8 ignore start */
58
+ if (typeof arg !== 'string')
59
+ throw new Error('invalid arg');
60
+ /* c8 ignore stop */
61
+ if (!arg.startsWith('--') || doubledash) {
62
+ result.push(arg);
63
+ continue;
64
+ }
65
+ if (arg === '--') {
66
+ result.push(arg);
67
+ doubledash = true;
68
+ continue;
69
+ }
70
+ const [eq, k, v] = getKeyValue(args, i);
71
+ if (!v) {
72
+ // wasn't a key-value pair
73
+ result.push(arg);
74
+ continue;
75
+ }
76
+ if (!eq)
77
+ i++;
78
+ if (doNotWantKeys.includes(k) && (importMatch(v) || legacyMatch(v))) {
79
+ // it's ours, remove it
80
+ continue;
81
+ }
82
+ // not ours, leave it
83
+ result.push(arg);
84
+ const next = args[i];
85
+ if (!eq && typeof next === 'string')
86
+ result.push(next);
87
+ continue;
88
+ }
89
+ return result;
90
+ };
24
91
  const addLoader = (args) => {
25
92
  const addKey = useImport ? '--import' : '--loader';
26
93
  const addValue = useImport ? importLoader : legacyLoader;
@@ -29,7 +96,7 @@ const addLoader = (args) => {
29
96
  useImport ? '--loader' : '--import',
30
97
  ];
31
98
  const test = useImport ? importMatch : legacyMatch;
32
- const added = [];
99
+ const result = [];
33
100
  let doubledash = false;
34
101
  let found = false;
35
102
  for (let i = 0; i < args.length; i++) {
@@ -39,18 +106,18 @@ const addLoader = (args) => {
39
106
  throw new Error('invalid arg');
40
107
  /* c8 ignore stop */
41
108
  if (!arg.startsWith('--') || doubledash) {
42
- added.push(arg);
109
+ result.push(arg);
43
110
  continue;
44
111
  }
45
112
  if (arg === '--') {
46
- added.push(arg);
113
+ result.push(arg);
47
114
  doubledash = true;
48
115
  continue;
49
116
  }
50
117
  const [eq, k, v] = getKeyValue(args, i);
51
118
  if (!v) {
52
119
  // wasn't a key-value pair
53
- added.push(arg);
120
+ result.push(arg);
54
121
  continue;
55
122
  }
56
123
  if (!eq)
@@ -64,30 +131,31 @@ const addLoader = (args) => {
64
131
  if (found)
65
132
  continue;
66
133
  found = true;
67
- added.push(arg);
134
+ result.push(arg);
68
135
  const next = args[i];
69
136
  if (!eq && typeof next === 'string')
70
- added.push(next);
137
+ result.push(next);
71
138
  }
72
139
  else {
73
140
  // not ours
74
- added.push(arg);
141
+ result.push(arg);
75
142
  const next = args[i];
76
143
  if (!eq && typeof next === 'string')
77
- added.push(next);
144
+ result.push(next);
78
145
  continue;
79
146
  }
80
147
  }
81
148
  if (!found)
82
- added.push(`${addKey}=${addValue}`);
83
- return !useImport ? addIgnoreLoadersWarning(added) : added;
149
+ result.push(`${addKey}=${addValue}`);
150
+ return !useImport ? addIgnoreLoadersWarning(result) : result;
84
151
  };
85
152
  const addIgnoreLoadersWarning = (args) => args.includes('--no-warnings') ||
86
153
  args.includes('--no-warnings=ExperimentalLoader')
87
154
  ? args
88
155
  : args.concat('--no-warnings');
89
- export const nodeOptionsEnv = (env) => {
156
+ export const nodeOptionsEnv = (env, args) => {
157
+ // if we already have the loader in args, don't add to NODE_OPTIONS
90
158
  const no = nodeOptionsToArgv(env.NODE_OPTIONS);
91
- return argvToNodeOptions(addLoader(no));
159
+ return argvToNodeOptions(hasLoader(args) ? rmLoader(no) : addLoader(no));
92
160
  };
93
161
  //# sourceMappingURL=node-options-env.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,YAAY,EACZ,WAAW,EAC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port {\n legacyLoader,\n legacyMatch,\n importLoader,\n importMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=') as [string, ...string[]]\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const added: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (!arg.startsWith('--') || doubledash) {\n added.push(arg)\n continue\n }\n if (arg === '--') {\n added.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n added.push(arg)\n continue\n }\n if (!eq) i++\n if (doNotWantKeys.includes(k) && (importMatch(v) || legacyMatch(v))) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n added.push(arg)\n const next = args[i]\n if (!eq && typeof next === 'string') added.push(next)\n } else {\n // not ours\n added.push(arg)\n const next = args[i]\n if (!eq && typeof next === 'string') added.push(next)\n continue\n }\n }\n if (!found) added.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(added) : added\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings')\n\nexport const nodeOptionsEnv = (env: NodeJS.ProcessEnv) => {\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(addLoader(no))\n}\n"]}
1
+ {"version":3,"file":"node-options-env.js","sourceRoot":"","sources":["../../src/node-options-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,WAAW,GACZ,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,CAClB,IAAuB,EACvB,CAAS,EAC8B,EAAE;IACzC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IACnB,qBAAqB;IACrB,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IAC3D,oBAAoB;IACpB,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACrB,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAA0B,CAAA;QAC5D,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;KACjC;SAAM,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9B,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;KACjC;SAAM;QACL,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,CAAA;KAC/B;AACH,CAAC,CA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M,CAAC,MAAM,cAAc,GAAG,CAC5B,GAAsB,EACtB,IAAuB,EACvB,EAAE;IACF,mEAAmE;IACnE,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC9C,OAAO,iBAAiB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AAC1E,CAAC,CAAA","sourcesContent":["import { argvToNodeOptions } from './argv-to-node-options.js'\nimport {\n importLoader,\n importMatch,\n legacyLoader,\n legacyMatch,\n} from './loader-paths.js'\nimport { nodeOptionsToArgv } from './node-options-to-argv.js'\n\nimport Module from 'node:module'\n\nconst getKeyValue = (\n args: readonly string[],\n i: number\n): [boolean, string, string | undefined] => {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (arg.includes('=')) {\n const [k, ...rest] = arg.split('=') as [string, ...string[]]\n return [true, k, rest.join('=')]\n } else if (i < args.length - 1) {\n return [false, arg, args[i + 1]]\n } else {\n return [false, arg, undefined]\n }\n}\n\nconst useImport = !!(Module as { register?: (...a: any[]) => any })\n .register\n\n// JUST test if we need to do anything at all with the env.\n// if the loader is set already in the args, even incorrectly, return true\nconst hasLoader = (args: readonly string[]): boolean => {\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (!arg.startsWith('--') || arg === '--') break\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n continue\n }\n if (!eq) i++\n if (\n (k === '--experimental-loader' || k === '--loader') &&\n legacyMatch(v)\n ) {\n return true\n }\n if (k === '--import' && importMatch(v)) return true\n }\n return false\n}\n\nconst rmLoader = (args: string[]) => {\n const doNotWantKeys = ['--experimental-loader', '--loader', '--import']\n\n const result: string[] = []\n\n let doubledash = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (!arg.startsWith('--') || doubledash) {\n result.push(arg)\n continue\n }\n if (arg === '--') {\n result.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n result.push(arg)\n continue\n }\n if (!eq) i++\n if (doNotWantKeys.includes(k) && (importMatch(v) || legacyMatch(v))) {\n // it's ours, remove it\n continue\n }\n // not ours, leave it\n result.push(arg)\n const next = args[i]\n if (!eq && typeof next === 'string') result.push(next)\n continue\n }\n return result\n}\n\nconst addLoader = (args: string[]) => {\n const addKey = useImport ? '--import' : '--loader'\n const addValue = useImport ? importLoader : legacyLoader\n const doNotWantKeys = [\n '--experimental-loader',\n useImport ? '--loader' : '--import',\n ]\n const test = useImport ? importMatch : legacyMatch\n\n const result: string[] = []\n\n let doubledash = false\n let found = false\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n /* c8 ignore start */\n if (typeof arg !== 'string') throw new Error('invalid arg')\n /* c8 ignore stop */\n if (!arg.startsWith('--') || doubledash) {\n result.push(arg)\n continue\n }\n if (arg === '--') {\n result.push(arg)\n doubledash = true\n continue\n }\n\n const [eq, k, v] = getKeyValue(args, i)\n if (!v) {\n // wasn't a key-value pair\n result.push(arg)\n continue\n }\n if (!eq) i++\n if (doNotWantKeys.includes(k) && (importMatch(v) || legacyMatch(v))) {\n // it's ours, but not how we want it, omit\n continue\n }\n\n if (k === addKey && test(v)) {\n // already present, don't let it be set multiple times.\n if (found) continue\n found = true\n result.push(arg)\n const next = args[i]\n if (!eq && typeof next === 'string') result.push(next)\n } else {\n // not ours\n result.push(arg)\n const next = args[i]\n if (!eq && typeof next === 'string') result.push(next)\n continue\n }\n }\n if (!found) result.push(`${addKey}=${addValue}`)\n return !useImport ? addIgnoreLoadersWarning(result) : result\n}\n\nconst addIgnoreLoadersWarning = (args: readonly string[]) =>\n args.includes('--no-warnings') ||\n args.includes('--no-warnings=ExperimentalLoader')\n ? args\n : args.concat('--no-warnings')\n\nexport const nodeOptionsEnv = (\n env: NodeJS.ProcessEnv,\n args: readonly string[]\n) => {\n // if we already have the loader in args, don't add to NODE_OPTIONS\n const no = nodeOptionsToArgv(env.NODE_OPTIONS)\n return argvToNodeOptions(hasLoader(args) ? rmLoader(no) : addLoader(no))\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAQxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AA6DnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SAmEjC,CAAA"}
1
+ {"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../src/register-coverage.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AASxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAwEnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SAuEjC,CAAA"}