cross-spawn-cb 2.4.14 → 2.5.1
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.
- package/dist/cjs/compat.d.cts +6 -0
- package/dist/cjs/compat.d.ts +6 -0
- package/dist/cjs/compat.js +47 -0
- package/dist/cjs/compat.js.map +1 -0
- package/dist/cjs/constants.d.cts +1 -0
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +12 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/crossSpawn.js +2 -1
- package/dist/cjs/crossSpawn.js.map +1 -1
- package/dist/cjs/shim/enoent.d.cts +10 -0
- package/dist/cjs/shim/enoent.d.ts +10 -0
- package/dist/cjs/shim/enoent.js +93 -0
- package/dist/cjs/shim/enoent.js.map +1 -0
- package/dist/cjs/shim/escape.d.cts +6 -0
- package/dist/cjs/shim/escape.d.ts +6 -0
- package/dist/cjs/shim/escape.js +45 -0
- package/dist/cjs/shim/escape.js.map +1 -0
- package/dist/cjs/shim/index.d.cts +25 -0
- package/dist/cjs/shim/index.d.ts +25 -0
- package/dist/cjs/shim/index.js +65 -0
- package/dist/cjs/shim/index.js.map +1 -0
- package/dist/cjs/shim/parse.d.cts +6 -0
- package/dist/cjs/shim/parse.d.ts +6 -0
- package/dist/cjs/shim/parse.js +120 -0
- package/dist/cjs/shim/parse.js.map +1 -0
- package/dist/cjs/shim/resolve.d.cts +6 -0
- package/dist/cjs/shim/resolve.d.ts +6 -0
- package/dist/cjs/shim/resolve.js +78 -0
- package/dist/cjs/shim/resolve.js.map +1 -0
- package/dist/cjs/shim/shebang.d.cts +5 -0
- package/dist/cjs/shim/shebang.d.ts +5 -0
- package/dist/cjs/shim/shebang.js +43 -0
- package/dist/cjs/shim/shebang.js.map +1 -0
- package/dist/cjs/shim/types.d.cts +24 -0
- package/dist/cjs/shim/types.d.ts +24 -0
- package/dist/cjs/shim/types.js +7 -0
- package/dist/cjs/shim/types.js.map +1 -0
- package/dist/esm/compat.d.ts +6 -0
- package/dist/esm/compat.js +28 -0
- package/dist/esm/compat.js.map +1 -0
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +1 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/crossSpawn.js +2 -1
- package/dist/esm/crossSpawn.js.map +1 -1
- package/dist/esm/shim/enoent.d.ts +10 -0
- package/dist/esm/shim/enoent.js +38 -0
- package/dist/esm/shim/enoent.js.map +1 -0
- package/dist/esm/shim/escape.d.ts +6 -0
- package/dist/esm/shim/escape.js +26 -0
- package/dist/esm/shim/escape.js.map +1 -0
- package/dist/esm/shim/index.d.ts +25 -0
- package/dist/esm/shim/index.js +37 -0
- package/dist/esm/shim/index.js.map +1 -0
- package/dist/esm/shim/parse.d.ts +6 -0
- package/dist/esm/shim/parse.js +102 -0
- package/dist/esm/shim/parse.js.map +1 -0
- package/dist/esm/shim/resolve.d.ts +6 -0
- package/dist/esm/shim/resolve.js +63 -0
- package/dist/esm/shim/resolve.js.map +1 -0
- package/dist/esm/shim/shebang.d.ts +5 -0
- package/dist/esm/shim/shebang.js +27 -0
- package/dist/esm/shim/shebang.js.map +1 -0
- package/dist/esm/shim/types.d.ts +24 -0
- package/dist/esm/shim/types.js +3 -0
- package/dist/esm/shim/types.js.map +1 -0
- package/package.json +15 -14
- package/assets/cross-spawn.cjs +0 -1947
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command resolution using which
|
|
3
|
+
* Simplified from cross-spawn v6.0.5
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "resolveCommand", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return resolveCommand;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _envpathkey = /*#__PURE__*/ _interop_require_default(require("env-path-key"));
|
|
15
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
16
|
+
var _which = /*#__PURE__*/ _interop_require_default(require("which"));
|
|
17
|
+
var _constantsts = require("../constants.js");
|
|
18
|
+
function _interop_require_default(obj) {
|
|
19
|
+
return obj && obj.__esModule ? obj : {
|
|
20
|
+
default: obj
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var pathDelimiter = _constantsts.isWindows ? ';' : ':';
|
|
24
|
+
var NODES = [
|
|
25
|
+
'node',
|
|
26
|
+
'node.exe',
|
|
27
|
+
'node.cmd'
|
|
28
|
+
];
|
|
29
|
+
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
30
|
+
var command = parsed.command;
|
|
31
|
+
var options = parsed.options;
|
|
32
|
+
var env = options.env || process.env;
|
|
33
|
+
var cwd = process.cwd();
|
|
34
|
+
var hasCustomCwd = options.cwd != null;
|
|
35
|
+
// Handle NODE/npm_node_execpath env vars for node commands
|
|
36
|
+
// This is needed because shebang detection may change the command to 'node'
|
|
37
|
+
// after the initial NODE env check in crossSpawn.ts has already passed
|
|
38
|
+
if (NODES.indexOf(_path.default.basename(command).toLowerCase()) >= 0) {
|
|
39
|
+
var nodeFromEnv = env.NODE || env.npm_node_execpath;
|
|
40
|
+
if (nodeFromEnv) {
|
|
41
|
+
return nodeFromEnv;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// If a custom cwd was specified, we need to change the process cwd
|
|
45
|
+
// because which will do stat calls but does not support a custom cwd
|
|
46
|
+
if (hasCustomCwd) {
|
|
47
|
+
try {
|
|
48
|
+
process.chdir(options.cwd);
|
|
49
|
+
} catch (_err) {
|
|
50
|
+
/* ignore */ }
|
|
51
|
+
}
|
|
52
|
+
var resolved = null;
|
|
53
|
+
var pathKey = (0, _envpathkey.default)({
|
|
54
|
+
env: options.env || process.env
|
|
55
|
+
}) || 'PATH';
|
|
56
|
+
try {
|
|
57
|
+
resolved = _which.default.sync(command, {
|
|
58
|
+
path: (options.env || process.env)[pathKey],
|
|
59
|
+
// On Windows: undefined uses PATHEXT, pathDelimiter bypasses it
|
|
60
|
+
// withoutPathExt fallback is needed to find files without extensions
|
|
61
|
+
pathExt: withoutPathExt ? pathDelimiter : undefined
|
|
62
|
+
});
|
|
63
|
+
} catch (_e) {
|
|
64
|
+
/* not found */ } finally{
|
|
65
|
+
if (hasCustomCwd) {
|
|
66
|
+
process.chdir(cwd);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Ensure absolute path
|
|
70
|
+
if (resolved) {
|
|
71
|
+
resolved = _path.default.resolve(hasCustomCwd ? options.cwd : '', resolved);
|
|
72
|
+
}
|
|
73
|
+
return resolved;
|
|
74
|
+
}
|
|
75
|
+
function resolveCommand(parsed) {
|
|
76
|
+
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
|
|
77
|
+
}
|
|
78
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/resolve.ts"],"sourcesContent":["/**\n * Command resolution using which\n * Simplified from cross-spawn v6.0.5\n */\n\nimport envPathKey from 'env-path-key';\nimport path from 'path';\nimport which from 'which';\nimport { isWindows } from '../constants.ts';\nimport type { Parsed } from './types.ts';\n\nconst pathDelimiter = isWindows ? ';' : ':';\nconst NODES = ['node', 'node.exe', 'node.cmd'];\n\nfunction resolveCommandAttempt(parsed: Parsed, withoutPathExt?: boolean): string | null {\n const command = parsed.command;\n const options = parsed.options;\n const env = options.env || process.env;\n const cwd = process.cwd();\n const hasCustomCwd = options.cwd != null;\n\n // Handle NODE/npm_node_execpath env vars for node commands\n // This is needed because shebang detection may change the command to 'node'\n // after the initial NODE env check in crossSpawn.ts has already passed\n if (NODES.indexOf(path.basename(command).toLowerCase()) >= 0) {\n const nodeFromEnv = env.NODE || env.npm_node_execpath;\n if (nodeFromEnv) {\n return nodeFromEnv;\n }\n }\n\n // If a custom cwd was specified, we need to change the process cwd\n // because which will do stat calls but does not support a custom cwd\n if (hasCustomCwd) {\n try {\n process.chdir(options.cwd as string);\n } catch (_err) {\n /* ignore */\n }\n }\n\n let resolved: string | null = null;\n const pathKey = envPathKey({ env: options.env || process.env }) || 'PATH';\n\n try {\n resolved = which.sync(command, {\n path: (options.env || process.env)[pathKey],\n // On Windows: undefined uses PATHEXT, pathDelimiter bypasses it\n // withoutPathExt fallback is needed to find files without extensions\n pathExt: withoutPathExt ? pathDelimiter : undefined,\n });\n } catch (_e) {\n /* not found */\n } finally {\n if (hasCustomCwd) {\n process.chdir(cwd);\n }\n }\n\n // Ensure absolute path\n if (resolved) {\n resolved = path.resolve(hasCustomCwd ? (options.cwd as string) : '', resolved);\n }\n\n return resolved;\n}\n\n// Try twice: first with PATHEXT (finds .cmd/.bat/.exe), then without (finds extensionless files)\nexport function resolveCommand(parsed: Parsed): string | null {\n return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);\n}\n"],"names":["resolveCommand","pathDelimiter","isWindows","NODES","resolveCommandAttempt","parsed","withoutPathExt","command","options","env","process","cwd","hasCustomCwd","indexOf","path","basename","toLowerCase","nodeFromEnv","NODE","npm_node_execpath","chdir","_err","resolved","pathKey","envPathKey","which","sync","pathExt","undefined","_e","resolve"],"mappings":"AAAA;;;CAGC;;;;+BAiEeA;;;eAAAA;;;iEA/DO;2DACN;4DACC;2BACQ;;;;;;AAG1B,IAAMC,gBAAgBC,sBAAS,GAAG,MAAM;AACxC,IAAMC,QAAQ;IAAC;IAAQ;IAAY;CAAW;AAE9C,SAASC,sBAAsBC,MAAc,EAAEC,cAAwB;IACrE,IAAMC,UAAUF,OAAOE,OAAO;IAC9B,IAAMC,UAAUH,OAAOG,OAAO;IAC9B,IAAMC,MAAMD,QAAQC,GAAG,IAAIC,QAAQD,G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
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "readShebang", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return readShebang;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _fs = /*#__PURE__*/ _interop_require_default(require("fs"));
|
|
15
|
+
var _compatts = require("../compat.js");
|
|
16
|
+
function _interop_require_default(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
var shebangRegex = /^#!.*/;
|
|
22
|
+
function parseShebang(str) {
|
|
23
|
+
var match = str.match(shebangRegex);
|
|
24
|
+
if (!match) return null;
|
|
25
|
+
var arr = match[0].replace(/#! ?/, '').split(' ');
|
|
26
|
+
var bin = arr[0].split('/').pop();
|
|
27
|
+
var arg = arr[1];
|
|
28
|
+
return bin === 'env' ? arg : bin + (arg ? " ".concat(arg) : '');
|
|
29
|
+
}
|
|
30
|
+
function readShebang(command) {
|
|
31
|
+
var size = 150;
|
|
32
|
+
var buffer = (0, _compatts.allocBuffer)(size);
|
|
33
|
+
var fd;
|
|
34
|
+
try {
|
|
35
|
+
fd = _fs.default.openSync(command, 'r');
|
|
36
|
+
_fs.default.readSync(fd, buffer, 0, size, 0);
|
|
37
|
+
_fs.default.closeSync(fd);
|
|
38
|
+
} catch (_e) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return parseShebang(buffer.toString());
|
|
42
|
+
}
|
|
43
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/shebang.ts"],"sourcesContent":["/**\n * Shebang detection for cross-platform script execution\n * Extracted from cross-spawn v6.0.5\n */\n\nimport fs from 'fs';\nimport { allocBuffer } from '../compat.ts';\n\nconst shebangRegex = /^#!.*/;\n\nfunction parseShebang(str: string): string | null {\n const match = str.match(shebangRegex);\n if (!match) return null;\n\n const arr = match[0].replace(/#! ?/, '').split(' ');\n const bin = arr[0].split('/').pop();\n const arg = arr[1];\n\n return bin === 'env' ? arg : bin + (arg ? ` ${arg}` : '');\n}\n\nexport function readShebang(command: string): string | null {\n const size = 150;\n const buffer = allocBuffer(size);\n\n let fd: number | undefined;\n try {\n fd = fs.openSync(command, 'r');\n fs.readSync(fd, buffer, 0, size, 0);\n fs.closeSync(fd);\n } catch (_e) {\n return null;\n }\n\n return parseShebang(buffer.toString());\n}\n"],"names":["readShebang","shebangRegex","parseShebang","str","match","arr","replace","split","bin","pop","arg","command","size","buffer","allocBuffer","fd","fs","openSync","readSync","closeSync","_e","toString"],"mappings":"AAAA;;;CAGC;;;;+BAkBeA;;;eAAAA;;;yDAhBD;wBACa;;;;;;AAE5B,IAAMC,eAAe;AAErB,SAASC,aAAaC,GAAW;IAC/B,IAAMC,QAAQD,IAAIC,KAAK,CAACH;IACxB,IAAI,CAACG,OAAO,OAAO;IAEnB,IAAMC,MAAMD,KAAK,CAAC,EAAE,CAACE,OAAO,CAAC,QAAQ,IAAIC,KAAK,CAAC;IAC/C,IAAMC,MAAMH,GAAG,CAAC,EAAE,CAACE,KAAK,CAAC,KAAKE,GAAG;IACjC,IAAMC,MAAML,GAAG,CAAC,EAAE;IAElB,OAAOG,QAAQ,QAAQE,MAAMF,MAAOE,CAAAA,MAAM,AAAC,IAAO,OAAJA,OAAQ,EAAC;AACzD;AAEO,SAASV,YAAYW,OAAe;IACzC,IAAMC,OAAO;IACb,IAAMC,SAASC,IAAAA,qBAAW,EAACF;IAE3B,IAAIG;IACJ,IAAI;QACFA,KAAKC,WAAE,CAACC,QAAQ,CAACN,SAAS;QAC1BK,WAAE,CAACE,QAAQ,CAACH,IAAIF,QAAQ,GAAGD,MAAM;QACjCI,WAAE,CAACG,SAAS,CAACJ;IACf,EAAE,OAAOK,IAAI;QACX,OAAO;IACT;IAEA,OAAOlB,aAAaW,OAAOQ,QAAQ;AACrC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the cross-spawn shim
|
|
3
|
+
*/
|
|
4
|
+
import type { SpawnOptions } from 'child_process';
|
|
5
|
+
export interface ShimSpawnOptions extends SpawnOptions {
|
|
6
|
+
forceShell?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Parsed {
|
|
9
|
+
command: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
options: ShimSpawnOptions;
|
|
12
|
+
file: string | null | undefined;
|
|
13
|
+
original: {
|
|
14
|
+
command: string;
|
|
15
|
+
args: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ENOENTError extends Error {
|
|
19
|
+
code: string;
|
|
20
|
+
errno: string;
|
|
21
|
+
syscall: string;
|
|
22
|
+
path: string;
|
|
23
|
+
spawnargs: string[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the cross-spawn shim
|
|
3
|
+
*/
|
|
4
|
+
import type { SpawnOptions } from 'child_process';
|
|
5
|
+
export interface ShimSpawnOptions extends SpawnOptions {
|
|
6
|
+
forceShell?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Parsed {
|
|
9
|
+
command: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
options: ShimSpawnOptions;
|
|
12
|
+
file: string | null | undefined;
|
|
13
|
+
original: {
|
|
14
|
+
command: string;
|
|
15
|
+
args: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface ENOENTError extends Error {
|
|
19
|
+
code: string;
|
|
20
|
+
errno: string;
|
|
21
|
+
syscall: string;
|
|
22
|
+
path: string;
|
|
23
|
+
spawnargs: string[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for the cross-spawn shim
|
|
3
|
+
*/ "use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/types.ts"],"sourcesContent":["/**\n * Types for the cross-spawn shim\n */\n\nimport type { SpawnOptions } from 'child_process';\n\nexport interface ShimSpawnOptions extends SpawnOptions {\n forceShell?: boolean;\n}\n\nexport interface Parsed {\n command: string;\n args: string[];\n options: ShimSpawnOptions;\n file: string | null | undefined;\n original: {\n command: string;\n args: string[];\n };\n}\n\nexport interface ENOENTError extends Error {\n code: string;\n errno: string;\n syscall: string;\n path: string;\n spawnargs: string[];\n}\n"],"names":[],"mappings":"AAAA;;CAEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility Layer for Node.js 0.8+
|
|
3
|
+
* Provides polyfills for features not available in older Node versions.
|
|
4
|
+
*/ // Buffer.alloc (Node 4.5+)
|
|
5
|
+
const hasBufferAlloc = typeof Buffer.alloc === 'function';
|
|
6
|
+
export function allocBuffer(size) {
|
|
7
|
+
if (hasBufferAlloc) {
|
|
8
|
+
return Buffer.alloc(size);
|
|
9
|
+
}
|
|
10
|
+
// Node < 4.5 fallback
|
|
11
|
+
const buffer = new Buffer(size);
|
|
12
|
+
buffer.fill(0);
|
|
13
|
+
return buffer;
|
|
14
|
+
}
|
|
15
|
+
// Object.assign (ES2015 / Node 4.0+)
|
|
16
|
+
const hasObjectAssign = typeof Object.assign === 'function';
|
|
17
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
18
|
+
export function objectAssign(target, source) {
|
|
19
|
+
if (hasObjectAssign) {
|
|
20
|
+
return Object.assign(target, source);
|
|
21
|
+
}
|
|
22
|
+
for(const key in source){
|
|
23
|
+
if (_hasOwnProperty.call(source, key)) {
|
|
24
|
+
target[key] = source[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Provides polyfills for features not available in older Node versions.\n */\n\n// Buffer.alloc (Node 4.5+)\nconst hasBufferAlloc = typeof Buffer.alloc === 'function';\n\nexport function allocBuffer(size: number): Buffer {\n if (hasBufferAlloc) {\n return Buffer.alloc(size);\n }\n // Node < 4.5 fallback\n const buffer = new (Buffer as unknown as new (size: number) => Buffer)(size);\n buffer.fill(0);\n return buffer;\n}\n\n// Object.assign (ES2015 / Node 4.0+)\nconst hasObjectAssign = typeof Object.assign === 'function';\nconst _hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport function objectAssign<T, U>(target: T, source: U): T & U {\n if (hasObjectAssign) {\n return Object.assign(target, source);\n }\n for (const key in source) {\n if (_hasOwnProperty.call(source, key)) {\n (target as Record<string, unknown>)[key] = (source as Record<string, unknown>)[key];\n }\n }\n return target as T & U;\n}\n"],"names":["hasBufferAlloc","Buffer","alloc","allocBuffer","size","buffer","fill","hasObjectAssign","Object","assign","_hasOwnProperty","prototype","hasOwnProperty","objectAssign","target","source","key","call"],"mappings":"AAAA;;;CAGC,GAED,2BAA2B;AAC3B,MAAMA,iBAAiB,OAAOC,OAAOC,KAAK,KAAK;AAE/C,OAAO,SAASC,YAAYC,IAAY;IACtC,IAAIJ,gBAAgB;QAClB,OAAOC,OAAOC,KAAK,CAACE;IACtB;IACA,sBAAsB;IACtB,MAAMC,SAAS,IAAKJ,OAAmDG;IACvEC,OAAOC,IAAI,CAAC;IACZ,OAAOD;AACT;AAEA,qCAAqC;AACrC,MAAME,kBAAkB,OAAOC,OAAOC,MAAM,KAAK;AACjD,MAAMC,kBAAkBF,OAAOG,SAAS,CAACC,cAAc;AAEvD,OAAO,SAASC,aAAmBC,MAAS,EAAEC,MAAS;IACrD,IAAIR,iBAAiB;QACnB,OAAOC,OAAOC,MAAM,CAACK,QAAQC;IAC/B;IACA,IAAK,MAAMC,OAAOD,OAAQ;QACxB,IAAIL,gBAAgBO,IAAI,CAACF,QAAQC,MAAM;YACpCF,MAAkC,CAACE,IAAI,GAAG,AAACD,MAAkC,CAACC,IAAI;QACrF;IACF;IACA,OAAOF;AACT"}
|
package/dist/esm/constants.d.ts
CHANGED
package/dist/esm/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/constants.ts"],"sourcesContent":["export const spawnKeys = ['pid', 'status', 'signal', 'stdout', 'stderr', 'output'];\n"],"names":["spawnKeys"],"mappings":"AAAA,OAAO,MAAMA,YAAY;IAAC;IAAO;IAAU;IAAU;IAAU;IAAU;CAAS,CAAC"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/constants.ts"],"sourcesContent":["export const spawnKeys = ['pid', 'status', 'signal', 'stdout', 'stderr', 'output'];\n\nexport const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n"],"names":["spawnKeys","isWindows","process","platform","test","env","OSTYPE"],"mappings":"AAAA,OAAO,MAAMA,YAAY;IAAC;IAAO;IAAU;IAAU;IAAU;IAAU;CAAS,CAAC;AAEnF,OAAO,MAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM,EAAE"}
|
package/dist/esm/crossSpawn.js
CHANGED
|
@@ -4,7 +4,8 @@ import path from 'path';
|
|
|
4
4
|
import spawnSyncPolyfill from './polyfills/spawnSync.js';
|
|
5
5
|
const major = +process.versions.node.split('.')[0];
|
|
6
6
|
const _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;
|
|
7
|
-
|
|
7
|
+
// Use lightweight shim for legacy Node (<= 7), modern cross-spawn for Node >= 8
|
|
8
|
+
const crossSpawn = _require(major <= 7 ? './shim/index.js' : 'cross-spawn');
|
|
8
9
|
export default function spawn(command, args, options) {
|
|
9
10
|
const parsed = spawn._parse(command, args, options);
|
|
10
11
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/crossSpawn.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport cp from 'child_process';\nimport Module from 'module';\nimport path from 'path';\nimport spawnSyncPolyfill from './polyfills/spawnSync.ts';\nimport type { Enoent, Parsed, SpawnOptions, SpawnResult, SpawnSyncOptions } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst crossSpawn = _require(major <= 7 ? '
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/crossSpawn.ts"],"sourcesContent":["import type { ChildProcess } from 'child_process';\nimport cp from 'child_process';\nimport Module from 'module';\nimport path from 'path';\nimport spawnSyncPolyfill from './polyfills/spawnSync.ts';\nimport type { Enoent, Parsed, SpawnOptions, SpawnResult, SpawnSyncOptions } from './types.ts';\n\nconst major = +process.versions.node.split('.')[0];\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n// Use lightweight shim for legacy Node (<= 7), modern cross-spawn for Node >= 8\nconst crossSpawn = _require(major <= 7 ? './shim/index.js' : 'cross-spawn');\n\nexport default function spawn(command: string, args: string[], options?: SpawnOptions): ChildProcess {\n const parsed = spawn._parse(command, args, options);\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n spawn._enoent.hookChildProcess(spawned, parsed);\n return spawned;\n}\n\nconst cpSpawnSync = cp.spawnSync || spawnSyncPolyfill;\nspawn.sync = function sync(command: string, args: string[], options?: SpawnSyncOptions): SpawnResult {\n const parsed = spawn._parse(command, args, options) as Parsed;\n const res = cpSpawnSync(parsed.command, parsed.args, parsed.options);\n res.error = res.error || spawn._enoent.verifyENOENTSync(res.status, parsed);\n return res;\n};\n\n// patch earlier versions of cross-spawn with inconsistent handling of node\nconst NODES = ['node', 'node.exe', 'node.cmd'];\nfunction _parse(command: string, args: string[], options?: SpawnOptions | SpawnSyncOptions): Parsed {\n if (NODES.indexOf(path.basename(command).toLowerCase()) >= 0) {\n const env = options ? options.env || process.env : process.env;\n command = env.NODE || env.npm_node_execpath || command;\n }\n return crossSpawn._parse(command, args, options);\n}\nspawn._parse = (major <= 7 ? _parse : crossSpawn._parse) as typeof _parse;\nspawn._enoent = crossSpawn._enoent as Enoent;\n"],"names":["cp","Module","path","spawnSyncPolyfill","major","process","versions","node","split","_require","require","createRequire","url","crossSpawn","spawn","command","args","options","parsed","_parse","spawned","_enoent","hookChildProcess","cpSpawnSync","spawnSync","sync","res","error","verifyENOENTSync","status","NODES","indexOf","basename","toLowerCase","env","NODE","npm_node_execpath"],"mappings":"AACA,OAAOA,QAAQ,gBAAgB;AAC/B,OAAOC,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,uBAAuB,2BAA2B;AAGzD,MAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,MAAMC,WAAW,OAAOC,YAAY,cAAcT,OAAOU,aAAa,CAAC,YAAYC,GAAG,IAAIF;AAC1F,gFAAgF;AAChF,MAAMG,aAAaJ,SAASL,SAAS,IAAI,oBAAoB;AAE7D,eAAe,SAASU,M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extracted from cross-spawn v6.0.5
|
|
4
|
+
*/
|
|
5
|
+
import type { ChildProcess } from 'child_process';
|
|
6
|
+
import type { ENOENTError, Parsed } from './types.js';
|
|
7
|
+
export declare function notFoundError(original: Parsed['original'], syscall: string): ENOENTError;
|
|
8
|
+
export declare function hookChildProcess(cp: ChildProcess, parsed: Parsed): void;
|
|
9
|
+
export declare function verifyENOENT(status: number, parsed: Parsed): ENOENTError | null;
|
|
10
|
+
export declare function verifyENOENTSync(status: number, parsed: Parsed): ENOENTError | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ENOENT error handling for Windows
|
|
3
|
+
* Extracted from cross-spawn v6.0.5
|
|
4
|
+
*/ import { isWindows } from '../constants.js';
|
|
5
|
+
export function notFoundError(original, syscall) {
|
|
6
|
+
const err = new Error(`${syscall} ${original.command} ENOENT`);
|
|
7
|
+
err.code = 'ENOENT';
|
|
8
|
+
err.errno = 'ENOENT';
|
|
9
|
+
err.syscall = `${syscall} ${original.command}`;
|
|
10
|
+
err.path = original.command;
|
|
11
|
+
err.spawnargs = original.args;
|
|
12
|
+
return err;
|
|
13
|
+
}
|
|
14
|
+
export function hookChildProcess(cp, parsed) {
|
|
15
|
+
if (!isWindows) return;
|
|
16
|
+
const originalEmit = cp.emit.bind(cp);
|
|
17
|
+
cp.emit = (name, ...args)=>{
|
|
18
|
+
if (name === 'exit') {
|
|
19
|
+
const err = verifyENOENT(args[0], parsed);
|
|
20
|
+
if (err) {
|
|
21
|
+
return originalEmit('error', err);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return originalEmit(name, ...args);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function verifyENOENT(status, parsed) {
|
|
28
|
+
if (isWindows && status === 1 && !parsed.file) {
|
|
29
|
+
return notFoundError(parsed.original, 'spawn');
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
export function verifyENOENTSync(status, parsed) {
|
|
34
|
+
if (isWindows && status === 1 && !parsed.file) {
|
|
35
|
+
return notFoundError(parsed.original, 'spawnSync');
|
|
36
|
+
}
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/enoent.ts"],"sourcesContent":["/**\n * ENOENT error handling for Windows\n * Extracted from cross-spawn v6.0.5\n */\n\nimport type { ChildProcess } from 'child_process';\nimport { isWindows } from '../constants.ts';\nimport type { ENOENTError, Parsed } from './types.ts';\n\nexport function notFoundError(original: Parsed['original'], syscall: string): ENOENTError {\n const err = new Error(`${syscall} ${original.command} ENOENT`) as ENOENTError;\n err.code = 'ENOENT';\n err.errno = 'ENOENT';\n err.syscall = `${syscall} ${original.command}`;\n err.path = original.command;\n err.spawnargs = original.args;\n return err;\n}\n\nexport function hookChildProcess(cp: ChildProcess, parsed: Parsed): void {\n if (!isWindows) return;\n\n const originalEmit = cp.emit.bind(cp);\n cp.emit = (name: string | symbol, ...args: unknown[]): boolean => {\n if (name === 'exit') {\n const err = verifyENOENT(args[0] as number, parsed);\n if (err) {\n return originalEmit('error', err);\n }\n }\n return originalEmit(name, ...args);\n };\n}\n\nexport function verifyENOENT(status: number, parsed: Parsed): ENOENTError | null {\n if (isWindows && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawn');\n }\n return null;\n}\n\nexport function verifyENOENTSync(status: number, parsed: Parsed): ENOENTError | null {\n if (isWindows && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawnSync');\n }\n return null;\n}\n"],"names":["isWindows","notFoundError","original","syscall","err","Error","command","code","errno","path","spawnargs","args","hookChildProcess","cp","parsed","originalEmit","emit","bind","name","verifyENOENT","status","file","verifyENOENTSync"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,SAAS,QAAQ,kBAAkB;AAG5C,OAAO,SAASC,cAAcC,QAA4B,EAAEC,OAAe;IACzE,MAAMC,MAAM,IAAIC,MAAM,GAAGF,QAAQ,CAAC,EAAED,SAASI,OAAO,CAAC,OAAO,CAAC;IAC7DF,IAAIG,IAAI,GAAG;IACXH,IAAII,KAAK,GAAG;IACZJ,IAAID,OAAO,GAAG,GAAGA,QAAQ,CAAC,EAAED,SAASI,OAAO,EAAE;IAC9CF,IAAIK,IAAI,GAAGP,SAASI,OAAO;IAC3BF,IAAIM,SAAS,GAAGR,SAASS,IAAI;IAC7B,OAAOP;AACT;AAEA,OAAO,SAASQ,iBAAiBC,EAAgB,EAAEC,MAAc;IAC/D,IAAI,CAACd,WAAW;IAEhB,MAAMe,eAAeF,GAAGG,IAAI,CAACC,IAAI,CAACJ;IAClCA,GAAGG,IAAI,GAAG,CAACE,MAAuB,GAAGP;QACnC,IAAIO,SAAS,QAAQ;YACnB,MAAMd,MAAMe,aAAaR,IAAI,CAAC,EAAE,EAAYG;YAC5C,IAAIV,KAAK;gBACP,OAAOW,aAAa,SAASX;YAC/B;QACF;QACA,OAAOW,aAAaG,SAASP;IAC/B;AACF;AAEA,OAAO,SAASQ,aAAaC,MAAc,EAAEN,MAAc;IACzD,IAAId,aAAaoB,WAAW,KAAK,CAACN,OAAOO,IAAI,EAAE;QAC7C,OAAOpB,cAAca,OAAOZ,QAAQ,EAAE;IACxC;IACA,OAAO;AACT;AAEA,OAAO,SAASoB,iBAAiBF,MAAc,EAAEN,MAAc;IAC7D,IAAId,aAAaoB,WAAW,KAAK,CAACN,OAAOO,IAAI,EAAE;QAC7C,OAAOpB,cAAca,OAAOZ,QAAQ,EAAE;IACxC;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows cmd.exe argument escaping
|
|
3
|
+
* Extracted from cross-spawn v6.0.5
|
|
4
|
+
*/ const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
5
|
+
export function escapeCommand(arg) {
|
|
6
|
+
return arg.replace(metaCharsRegExp, '^$1');
|
|
7
|
+
}
|
|
8
|
+
export function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
9
|
+
// Convert to string
|
|
10
|
+
arg = `${arg}`;
|
|
11
|
+
// Sequence of backslashes followed by a double quote:
|
|
12
|
+
// double up all the backslashes and escape the double quote
|
|
13
|
+
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
|
14
|
+
// Sequence of backslashes followed by the end of the string:
|
|
15
|
+
// double up all the backslashes
|
|
16
|
+
arg = arg.replace(/(\\*)$/, '$1$1');
|
|
17
|
+
// Quote the whole thing
|
|
18
|
+
arg = `"${arg}"`;
|
|
19
|
+
// Escape meta chars
|
|
20
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
21
|
+
// Double escape meta chars if necessary
|
|
22
|
+
if (doubleEscapeMetaChars) {
|
|
23
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
24
|
+
}
|
|
25
|
+
return arg;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/escape.ts"],"sourcesContent":["/**\n * Windows cmd.exe argument escaping\n * Extracted from cross-spawn v6.0.5\n */\n\nconst metaCharsRegExp = /([()\\][%!^\"`<>&|;, *?])/g;\n\nexport function escapeCommand(arg: string): string {\n return arg.replace(metaCharsRegExp, '^$1');\n}\n\nexport function escapeArgument(arg: string, doubleEscapeMetaChars?: boolean): string {\n // Convert to string\n arg = `${arg}`;\n\n // Sequence of backslashes followed by a double quote:\n // double up all the backslashes and escape the double quote\n arg = arg.replace(/(\\\\*)\"/g, '$1$1\\\\\"');\n\n // Sequence of backslashes followed by the end of the string:\n // double up all the backslashes\n arg = arg.replace(/(\\\\*)$/, '$1$1');\n\n // Quote the whole thing\n arg = `\"${arg}\"`;\n\n // Escape meta chars\n arg = arg.replace(metaCharsRegExp, '^$1');\n\n // Double escape meta chars if necessary\n if (doubleEscapeMetaChars) {\n arg = arg.replace(metaCharsRegExp, '^$1');\n }\n\n return arg;\n}\n"],"names":["metaCharsRegExp","escapeCommand","arg","replace","escapeArgument","doubleEscapeMetaChars"],"mappings":"AAAA;;;CAGC,GAED,MAAMA,kBAAkB;AAExB,OAAO,SAASC,cAAcC,GAAW;IACvC,OAAOA,IAAIC,OAAO,CAACH,iBAAiB;AACtC;AAEA,OAAO,SAASI,eAAeF,GAAW,EAAEG,qBAA+B;IACzE,oBAAoB;IACpBH,MAAM,GAAGA,KAAK;IAEd,sDAAsD;IACtD,4DAA4D;IAC5DA,MAAMA,IAAIC,OAAO,CAAC,WAAW;IAE7B,6DAA6D;IAC7D,gCAAgC;IAChCD,MAAMA,IAAIC,OAAO,CAAC,UAAU;IAE5B,wBAAwB;IACxBD,MAAM,CAAC,CAAC,EAAEA,IAAI,CAAC,CAAC;IAEhB,oBAAoB;IACpBA,MAAMA,IAAIC,OAAO,CAACH,iBAAiB;IAEnC,wCAAwC;IACxC,IAAIK,uBAAuB;QACzBH,MAAMA,IAAIC,OAAO,CAACH,iBAAiB;IACrC;IAEA,OAAOE;AACT"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal cross-spawn shim for Windows compatibility on legacy Node.js
|
|
3
|
+
*
|
|
4
|
+
* This replaces the bundled cross-spawn v6.0.5 (~1,950 lines) with a minimal
|
|
5
|
+
* implementation (~200 lines) that uses external dependencies:
|
|
6
|
+
* - which@^1.0.0 (command resolution)
|
|
7
|
+
* - env-path-key@^1.0.0 (cross-platform PATH key detection)
|
|
8
|
+
*/
|
|
9
|
+
import type { ChildProcess, SpawnSyncReturns } from 'child_process';
|
|
10
|
+
import { hookChildProcess, notFoundError, verifyENOENT, verifyENOENTSync } from './enoent.js';
|
|
11
|
+
import { parse } from './parse.js';
|
|
12
|
+
import type { Parsed, ShimSpawnOptions } from './types.js';
|
|
13
|
+
declare function spawn(command: string, args?: string[] | ShimSpawnOptions, options?: ShimSpawnOptions): ChildProcess;
|
|
14
|
+
declare function spawnSync(command: string, args?: string[] | ShimSpawnOptions, options?: ShimSpawnOptions): SpawnSyncReturns<Buffer>;
|
|
15
|
+
export default spawn;
|
|
16
|
+
export { spawn };
|
|
17
|
+
export { spawnSync as sync };
|
|
18
|
+
export { parse as _parse };
|
|
19
|
+
export declare const _enoent: {
|
|
20
|
+
hookChildProcess: typeof hookChildProcess;
|
|
21
|
+
verifyENOENT: typeof verifyENOENT;
|
|
22
|
+
verifyENOENTSync: typeof verifyENOENTSync;
|
|
23
|
+
notFoundError: typeof notFoundError;
|
|
24
|
+
};
|
|
25
|
+
export type { Parsed, ShimSpawnOptions };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal cross-spawn shim for Windows compatibility on legacy Node.js
|
|
3
|
+
*
|
|
4
|
+
* This replaces the bundled cross-spawn v6.0.5 (~1,950 lines) with a minimal
|
|
5
|
+
* implementation (~200 lines) that uses external dependencies:
|
|
6
|
+
* - which@^1.0.0 (command resolution)
|
|
7
|
+
* - env-path-key@^1.0.0 (cross-platform PATH key detection)
|
|
8
|
+
*/ import cp from 'child_process';
|
|
9
|
+
import spawnSyncPolyfill from '../polyfills/spawnSync.js';
|
|
10
|
+
import { hookChildProcess, notFoundError, verifyENOENT, verifyENOENTSync } from './enoent.js';
|
|
11
|
+
import { parse } from './parse.js';
|
|
12
|
+
const cpSpawnSync = cp.spawnSync || spawnSyncPolyfill;
|
|
13
|
+
function spawn(command, args, options) {
|
|
14
|
+
const parsed = parse(command, args, options);
|
|
15
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
16
|
+
hookChildProcess(spawned, parsed);
|
|
17
|
+
return spawned;
|
|
18
|
+
}
|
|
19
|
+
function spawnSync(command, args, options) {
|
|
20
|
+
const parsed = parse(command, args, options);
|
|
21
|
+
const result = cpSpawnSync(parsed.command, parsed.args, parsed.options);
|
|
22
|
+
result.error = result.error || verifyENOENTSync(result.status, parsed);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
// Main export
|
|
26
|
+
export default spawn;
|
|
27
|
+
// Named exports matching cross-spawn's API
|
|
28
|
+
export { spawn };
|
|
29
|
+
export { spawnSync as sync };
|
|
30
|
+
// Internal APIs used by crossSpawn.ts
|
|
31
|
+
export { parse as _parse };
|
|
32
|
+
export const _enoent = {
|
|
33
|
+
hookChildProcess,
|
|
34
|
+
verifyENOENT,
|
|
35
|
+
verifyENOENTSync,
|
|
36
|
+
notFoundError
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/index.ts"],"sourcesContent":["/**\n * Minimal cross-spawn shim for Windows compatibility on legacy Node.js\n *\n * This replaces the bundled cross-spawn v6.0.5 (~1,950 lines) with a minimal\n * implementation (~200 lines) that uses external dependencies:\n * - which@^1.0.0 (command resolution)\n * - env-path-key@^1.0.0 (cross-platform PATH key detection)\n */\n\nimport type { ChildProcess, SpawnSyncReturns } from 'child_process';\nimport cp from 'child_process';\nimport spawnSyncPolyfill from '../polyfills/spawnSync.ts';\nimport { hookChildProcess, notFoundError, verifyENOENT, verifyENOENTSync } from './enoent.ts';\nimport { parse } from './parse.ts';\nimport type { Parsed, ShimSpawnOptions } from './types.ts';\n\nconst cpSpawnSync = cp.spawnSync || spawnSyncPolyfill;\n\nfunction spawn(command: string, args?: string[] | ShimSpawnOptions, options?: ShimSpawnOptions): ChildProcess {\n const parsed = parse(command, args, options);\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n hookChildProcess(spawned, parsed);\n return spawned;\n}\n\nfunction spawnSync(command: string, args?: string[] | ShimSpawnOptions, options?: ShimSpawnOptions): SpawnSyncReturns<Buffer> {\n const parsed = parse(command, args, options);\n const result = cpSpawnSync(parsed.command, parsed.args, parsed.options) as SpawnSyncReturns<Buffer> & { error?: Error };\n result.error = result.error || verifyENOENTSync(result.status as number, parsed);\n return result;\n}\n\n// Main export\nexport default spawn;\n\n// Named exports matching cross-spawn's API\nexport { spawn };\nexport { spawnSync as sync };\n\n// Internal APIs used by crossSpawn.ts\nexport { parse as _parse };\nexport const _enoent = {\n hookChildProcess,\n verifyENOENT,\n verifyENOENTSync,\n notFoundError,\n};\n\n// Re-export types\nexport type { Parsed, ShimSpawnOptions };\n"],"names":["cp","spawnSyncPolyfill","hookChildProcess","notFoundError","verifyENOENT","verifyENOENTSync","parse","cpSpawnSync","spawnSync","spawn","command","args","options","parsed","spawned","result","error","status","sync","_parse","_enoent"],"mappings":"AAAA;;;;;;;CAOC,GAGD,OAAOA,QAAQ,gBAAgB;AAC/B,OAAOC,uBAAuB,4BAA4B;AAC1D,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,YAAY,EAAEC,gBAAgB,QAAQ,cAAc;AAC9F,SAASC,KAAK,QAAQ,aAAa;AAGnC,MAAMC,cAAcP,GAAGQ,SAAS,IAAIP;AAEpC,SAASQ,MAAMC,OAAe,EAAEC,IAAkC,EAAEC,OAA0B;IAC5F,MAAMC,SAASP,MAAMI,SAASC,MAAMC;IACpC,MAAME,UAAUd,GAAGS,KAAK,CAACI,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACpEV,iBAAiBY,SAASD;IAC1B,OAAOC;AACT;AAEA,SAASN,UAAUE,OAAe,EAAEC,IAAkC,EAAEC,OAA0B;IAChG,MAAMC,SAASP,MAAMI,SAASC,MAAMC;IACpC,MAAMG,SAASR,YAAYM,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACtEG,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIX,iBAAiBU,OAAOE,MAAM,EAAYJ;IACzE,OAAOE;AACT;AAEA,cAAc;AACd,eAAeN,MAAM;AAErB,2CAA2C;AAC3C,SAASA,KAAK,GAAG;AACjB,SAASD,aAAaU,IAAI,GAAG;AAE7B,sCAAsC;AACtC,SAASZ,SAASa,MAAM,GAAG;AAC3B,OAAO,MAAMC,UAAU;IACrBlB;IACAE;IACAC;IACAF;AACF,EAAE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command parsing for cross-platform spawn
|
|
3
|
+
* Simplified from cross-spawn v6.0.5
|
|
4
|
+
*/
|
|
5
|
+
import type { Parsed, ShimSpawnOptions } from './types.js';
|
|
6
|
+
export declare function parse(command: string, args?: string[] | ShimSpawnOptions | null, options?: ShimSpawnOptions): Parsed;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command parsing for cross-platform spawn
|
|
3
|
+
* Simplified from cross-spawn v6.0.5
|
|
4
|
+
*/ import path from 'path';
|
|
5
|
+
import { objectAssign } from '../compat.js';
|
|
6
|
+
import { isWindows } from '../constants.js';
|
|
7
|
+
import { escapeArgument, escapeCommand } from './escape.js';
|
|
8
|
+
import { resolveCommand } from './resolve.js';
|
|
9
|
+
import { readShebang } from './shebang.js';
|
|
10
|
+
const isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
11
|
+
const isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
12
|
+
function detectShebang(parsed) {
|
|
13
|
+
parsed.file = resolveCommand(parsed);
|
|
14
|
+
const shebang = parsed.file && readShebang(parsed.file);
|
|
15
|
+
if (shebang) {
|
|
16
|
+
parsed.args.unshift(parsed.file);
|
|
17
|
+
parsed.command = shebang;
|
|
18
|
+
return resolveCommand(parsed);
|
|
19
|
+
}
|
|
20
|
+
return parsed.file;
|
|
21
|
+
}
|
|
22
|
+
function parseNonShell(parsed) {
|
|
23
|
+
if (!isWindows) return parsed;
|
|
24
|
+
// Detect & add support for shebangs
|
|
25
|
+
const commandFile = detectShebang(parsed);
|
|
26
|
+
// We don't need a shell if the command filename is an executable
|
|
27
|
+
const needsShell = !isExecutableRegExp.test(commandFile || '');
|
|
28
|
+
if (parsed.options.forceShell || needsShell) {
|
|
29
|
+
// Need to double escape meta chars if the command is a cmd-shim
|
|
30
|
+
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile || '');
|
|
31
|
+
// Normalize posix paths into OS compatible paths
|
|
32
|
+
parsed.command = path.normalize(parsed.command);
|
|
33
|
+
// Escape command & arguments
|
|
34
|
+
parsed.command = escapeCommand(parsed.command);
|
|
35
|
+
parsed.args = parsed.args.map((arg)=>escapeArgument(arg, needsDoubleEscapeMetaChars));
|
|
36
|
+
const shellCommand = [
|
|
37
|
+
parsed.command
|
|
38
|
+
].concat(parsed.args).join(' ');
|
|
39
|
+
parsed.args = [
|
|
40
|
+
'/d',
|
|
41
|
+
'/s',
|
|
42
|
+
'/c',
|
|
43
|
+
`"${shellCommand}"`
|
|
44
|
+
];
|
|
45
|
+
parsed.command = process.env.comspec || 'cmd.exe';
|
|
46
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
47
|
+
}
|
|
48
|
+
return parsed;
|
|
49
|
+
}
|
|
50
|
+
function parseShell(parsed) {
|
|
51
|
+
// Mimic node shell option for older Node versions
|
|
52
|
+
const shellCommand = [
|
|
53
|
+
parsed.command
|
|
54
|
+
].concat(parsed.args).join(' ');
|
|
55
|
+
if (isWindows) {
|
|
56
|
+
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
|
|
57
|
+
parsed.args = [
|
|
58
|
+
'/d',
|
|
59
|
+
'/s',
|
|
60
|
+
'/c',
|
|
61
|
+
`"${shellCommand}"`
|
|
62
|
+
];
|
|
63
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
64
|
+
} else {
|
|
65
|
+
if (typeof parsed.options.shell === 'string') {
|
|
66
|
+
parsed.command = parsed.options.shell;
|
|
67
|
+
} else if (process.platform === 'android') {
|
|
68
|
+
parsed.command = '/system/bin/sh';
|
|
69
|
+
} else {
|
|
70
|
+
parsed.command = '/bin/sh';
|
|
71
|
+
}
|
|
72
|
+
parsed.args = [
|
|
73
|
+
'-c',
|
|
74
|
+
shellCommand
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
return parsed;
|
|
78
|
+
}
|
|
79
|
+
export function parse(command, args, options) {
|
|
80
|
+
// Normalize arguments
|
|
81
|
+
let argsArray;
|
|
82
|
+
let opts;
|
|
83
|
+
if (args && !Array.isArray(args)) {
|
|
84
|
+
// args is actually options
|
|
85
|
+
argsArray = [];
|
|
86
|
+
opts = objectAssign({}, args);
|
|
87
|
+
} else {
|
|
88
|
+
argsArray = args ? args.slice(0) : [];
|
|
89
|
+
opts = objectAssign({}, options || {});
|
|
90
|
+
}
|
|
91
|
+
const parsed = {
|
|
92
|
+
command: command,
|
|
93
|
+
args: argsArray,
|
|
94
|
+
options: opts,
|
|
95
|
+
file: undefined,
|
|
96
|
+
original: {
|
|
97
|
+
command: command,
|
|
98
|
+
args: argsArray
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return opts.shell ? parseShell(parsed) : parseNonShell(parsed);
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/shim/parse.ts"],"sourcesContent":["/**\n * Command parsing for cross-platform spawn\n * Simplified from cross-spawn v6.0.5\n */\n\nimport path from 'path';\nimport { objectAssign } from '../compat.ts';\nimport { isWindows } from '../constants.ts';\nimport { escapeArgument, escapeCommand } from './escape.ts';\nimport { resolveCommand } from './resolve.ts';\nimport { readShebang } from './shebang.ts';\nimport type { Parsed, ShimSpawnOptions } from './types.ts';\n\nconst isExecutableRegExp = /\\.(?:com|exe)$/i;\nconst isCmdShimRegExp = /node_modules[\\\\/].bin[\\\\/][^\\\\/]+\\.cmd$/i;\n\nfunction detectShebang(parsed: Parsed): string | null {\n parsed.file = resolveCommand(parsed);\n\n const shebang = parsed.file && readShebang(parsed.file);\n if (shebang) {\n parsed.args.unshift(parsed.file);\n parsed.command = shebang;\n return resolveCommand(parsed);\n }\n\n return parsed.file;\n}\n\nfunction parseNonShell(parsed: Parsed): Parsed {\n if (!isWindows) return parsed;\n\n // Detect & add support for shebangs\n const commandFile = detectShebang(parsed);\n\n // We don't need a shell if the command filename is an executable\n const needsShell = !isExecutableRegExp.test(commandFile || '');\n\n if (parsed.options.forceShell || needsShell) {\n // Need to double escape meta chars if the command is a cmd-shim\n const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile || '');\n\n // Normalize posix paths into OS compatible paths\n parsed.command = path.normalize(parsed.command);\n\n // Escape command & arguments\n parsed.command = escapeCommand(parsed.command);\n parsed.args = parsed.args.map((arg) => escapeArgument(arg, needsDoubleEscapeMetaChars));\n\n const shellCommand = [parsed.command].concat(parsed.args).join(' ');\n\n parsed.args = ['/d', '/s', '/c', `\"${shellCommand}\"`];\n parsed.command = process.env.comspec || 'cmd.exe';\n parsed.options.windowsVerbatimArguments = true;\n }\n\n return parsed;\n}\n\nfunction parseShell(parsed: Parsed): Parsed {\n // Mimic node shell option for older Node versions\n const shellCommand = [parsed.command].concat(parsed.args).join(' ');\n\n if (isWindows) {\n parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';\n parsed.args = ['/d', '/s', '/c', `\"${shellCommand}\"`];\n parsed.options.windowsVerbatimArguments = true;\n } else {\n if (typeof parsed.options.shell === 'string') {\n parsed.command = parsed.options.shell;\n } else if (process.platform === 'android') {\n parsed.command = '/system/bin/sh';\n } else {\n parsed.command = '/bin/sh';\n }\n parsed.args = ['-c', shellCommand];\n }\n\n return parsed;\n}\n\nexport function parse(command: string, args?: string[] | ShimSpawnOptions | null, options?: ShimSpawnOptions): Parsed {\n // Normalize arguments\n let argsArray: string[];\n let opts: ShimSpawnOptions;\n\n if (args && !Array.isArray(args)) {\n // args is actually options\n argsArray = [];\n opts = objectAssign({}, args);\n } else {\n argsArray = args ? (args as string[]).slice(0) : [];\n opts = objectAssign({}, options || {});\n }\n\n const parsed: Parsed = {\n command: command,\n args: argsArray,\n options: opts,\n file: undefined,\n original: {\n command: command,\n args: argsArray,\n },\n };\n\n return opts.shell ? parseShell(parsed) : parseNonShell(parsed);\n}\n"],"names":["path","objectAssign","isWindows","escapeArgument","escapeCommand","resolveCommand","readShebang","isExecutableRegExp","isCmdShimRegExp","detectShebang","parsed","file","shebang","args","unshift","command","parseNonShell","commandFile","needsShell","test","options","forceShell","needsDoubleEscapeMetaChars","normalize","map","arg","shellCommand","concat","join","process","env","comspec","windowsVerbatimArguments","parseShell","shell","platform","parse","argsArray","opts","Array","isArray","slice","undefined","original"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,OAAO;AACxB,SAASC,YAAY,QAAQ,eAAe;AAC5C,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAC5D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,WAAW,QAAQ,eAAe;AAG3C,MAAMC,qBAAqB;AAC3B,MAAMC,kBAAkB;AAExB,SAASC,cAAcC,MAAc;IACnCA,OAAOC,IAAI,GAAGN,eAAeK;IAE7B,MAAME,UAAUF,OAAOC,IAAI,IAAIL,YAAYI,OAAOC,IAAI;IACtD,IAAIC,SAAS;QACXF,OAAOG,IAAI,CAACC,OAAO,CAACJ,OAAOC,IAAI;QAC/BD,OAAOK,OAAO,GAAGH;QACjB,OAAOP,eAAeK;IACxB;IAEA,OAAOA,OAAOC,IAAI;AACpB;AAEA,SAASK,cAAcN,MAAc;IACnC,IAAI,CAACR,WAAW,OAAOQ;IAEvB,oCAAoC;IACpC,MAAMO,cAAcR,cAAcC;IAElC,iEAAiE;IACjE,MAAMQ,aAAa,CAACX,mBAAmBY,IAAI,CAACF,eAAe;IAE3D,IAAIP,OAAOU,OAAO,CAACC,UAAU,IAAIH,YAAY;QAC3C,gEAAgE;QAChE,MAAMI,6BAA6Bd,gBAAgBW,IAAI,CAACF,eAAe;QAEvE,iDAAiD;QACjDP,OAAOK,OAAO,GAAGf,KAAKuB,SAAS,CAACb,OAAOK,OAAO;Q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