cross-spawn-cb 2.4.13 → 2.5.0
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.js +1 -1
- package/dist/cjs/crossSpawn.js +3 -2
- package/dist/cjs/crossSpawn.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/polyfills/spawnSync.js +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 +57 -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/cjs/spawn.js +1 -1
- package/dist/cjs/spawnSync.js +1 -1
- package/dist/cjs/types.js +1 -1
- package/dist/cjs/workers/async.js +1 -1
- package/dist/cjs/workers/sync.js +1 -1
- 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/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 +41 -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 +16 -15
- package/assets/cross-spawn.cjs +0 -1947
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get allocBuffer () {
|
|
13
|
+
return allocBuffer;
|
|
14
|
+
},
|
|
15
|
+
get objectAssign () {
|
|
16
|
+
return objectAssign;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Compatibility Layer for Node.js 0.8+
|
|
21
|
+
* Provides polyfills for features not available in older Node versions.
|
|
22
|
+
*/ // Buffer.alloc (Node 4.5+)
|
|
23
|
+
var hasBufferAlloc = typeof Buffer.alloc === 'function';
|
|
24
|
+
function allocBuffer(size) {
|
|
25
|
+
if (hasBufferAlloc) {
|
|
26
|
+
return Buffer.alloc(size);
|
|
27
|
+
}
|
|
28
|
+
// Node < 4.5 fallback
|
|
29
|
+
var buffer = new Buffer(size);
|
|
30
|
+
buffer.fill(0);
|
|
31
|
+
return buffer;
|
|
32
|
+
}
|
|
33
|
+
// Object.assign (ES2015 / Node 4.0+)
|
|
34
|
+
var hasObjectAssign = typeof Object.assign === 'function';
|
|
35
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
36
|
+
function objectAssign(target, source) {
|
|
37
|
+
if (hasObjectAssign) {
|
|
38
|
+
return Object.assign(target, source);
|
|
39
|
+
}
|
|
40
|
+
for(var key in source){
|
|
41
|
+
if (_hasOwnProperty.call(source, key)) {
|
|
42
|
+
target[key] = source[key];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
}
|
|
47
|
+
/* 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/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":["allocBuffer","objectAssign","hasBufferAlloc","Buffer","alloc","size","buffer","fill","hasObjectAssign","Object","assign","_hasOwnProperty","prototype","hasOwnProperty","target","source","key","call"],"mappings":";;;;;;;;;;;QAQgBA;eAAAA;;QAcAC;eAAAA;;;AAtBhB;;;CAGC,GAED,2BAA2B;AAC3B,IAAMC,iBAAiB,OAAOC,OAAOC,KAAK,KAAK;AAExC,SAASJ,YAAYK,IAAY;IACtC,IAAIH,gBAAgB;QAClB,OAAOC,OAAOC,KAAK,CAACC;IACtB;IACA,sBAAsB;IACtB,IAAMC,SAAS,IAAKH,OAAmDE;IACvEC,OAAOC,IAAI,CAAC;IACZ,OAAOD;AACT;AAEA,qCAAqC;AACrC,IAAME,kBAAkB,OAAOC,OAAOC,MAAM,KAAK;AACjD,IAAMC,kBAAkBF,OAAOG,SAAS,CAACC,cAAc;AAEhD,SAASZ,aAAmBa,MAAS,EAAEC,MAAS;IACrD,IAAIP,iBAAiB;QACnB,OAAOC,OAAOC,MAAM,CAACI,QAAQC;IAC/B;IACA,IAAK,IAAMC,OAAOD,OAAQ;QACxB,IAAIJ,gBAAgBM,IAAI,CAACF,QAAQC,MAAM;YACpCF,MAAkC,CAACE,IAAI,GAAG,AAACD,MAAkC,CAACC,IAAI;QACrF;IACF;IACA,OAAOF;AACT"}
|
package/dist/cjs/constants.js
CHANGED
|
@@ -16,4 +16,4 @@ var spawnKeys = [
|
|
|
16
16
|
'stderr',
|
|
17
17
|
'output'
|
|
18
18
|
];
|
|
19
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
19
|
+
/* 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; }
|
package/dist/cjs/crossSpawn.js
CHANGED
|
@@ -19,7 +19,8 @@ function _interop_require_default(obj) {
|
|
|
19
19
|
}
|
|
20
20
|
var major = +process.versions.node.split('.')[0];
|
|
21
21
|
var _require = typeof require === 'undefined' ? _module.default.createRequire(require("url").pathToFileURL(__filename).toString()) : require;
|
|
22
|
-
|
|
22
|
+
// Use lightweight shim for legacy Node (<= 7), modern cross-spawn for Node >= 8
|
|
23
|
+
var crossSpawn = _require(major <= 7 ? './shim/index.js' : 'cross-spawn');
|
|
23
24
|
function spawn(command, args, options) {
|
|
24
25
|
var parsed = spawn._parse(command, args, options);
|
|
25
26
|
var spawned = _child_process.default.spawn(parsed.command, parsed.args, parsed.options);
|
|
@@ -48,4 +49,4 @@ function _parse(command, args, options) {
|
|
|
48
49
|
}
|
|
49
50
|
spawn._parse = major <= 7 ? _parse : crossSpawn._parse;
|
|
50
51
|
spawn._enoent = crossSpawn._enoent;
|
|
51
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
52
|
+
/* 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; }
|
|
@@ -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":["spawn","major","process","versions","node","split","_require","require","Module","createRequire","crossSpawn","command","args","options","parsed","_parse","spawned","cp","_enoent","hookChildProcess","cpSpawnSync","spawnSync","spawnSyncPolyfill","sync","res","error","verifyENOENTSync","status","NODES","indexOf","path","basename","toLowerCase","env","NODE","npm_node_execpath"],"mappings":";;;;+BAYA;;;eAAwBA;;;oEAXT;6DACI;2DACF;kEACa;;;;;;AAG9B,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,gFAAgF;AAChF,IAAMG,aAAaJ,SAASL,SAAS,IAAI,oBAAoB;AAE9C,SAASD,MAAMW,OAAe,EAAEC,IAAc,EAAEC,OAAsB;IACnF,IAAMC,SAASd,MAAMe,MAAM,CAACJ,SAASC,MAAMC;IAC3C,IAAMG,UAAUC,sBAAE,CAACjB,KAAK,CAACc,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACpEb,MAAMkB,OAAO,CAACC,gBAAgB,CAACH,SAASF;IACxC,OAAOE;AACT;AAEA,IAAMI,cAAcH,sBAAE,CAACI,SAAS,IAAIC,oBAAiB;AACrDtB,MAAMuB,IAAI,GAAG,SAASA,KAAKZ,OAAe,EAAEC,IAAc,EAAEC,OAA0B;IACpF,IAAMC,SAASd,MAAMe,MAAM,CAACJ,SAASC,MAAMC;IAC3C,IAAMW,MAAMJ,YAAYN,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACnEW,IAAIC,KAAK,GAAGD,IAAIC,KAAK,IAAIzB,MAAMkB,OAAO,CAACQ,gBAAgB,CAACF,IAAIG,MAAM,EAAEb;IACpE,OAAOU;AACT;AAEA,2EAA2E;AAC3E,IAAMI,QAAQ;IAAC;IAAQ;IAAY;CAAW;AAC9C,SAASb,OAAOJ,OAAe,EAAEC,IAAc,EAAEC,OAAyC;IACxF,IAAIe,MAAMC,OAAO,CAACC,aAAI,CAACC,QAAQ,CAACpB,SAASqB,WAAW,OAAO,GAAG;QAC5D,IAAMC,MAAMpB,UAAUA,QAAQoB,GAAG,IAAI/B,QAAQ+B,GAAG,GAAG/B,QAAQ+B,GAAG;QAC9DtB,UAAUsB,IAAIC,IAAI,IAAID,IAAIE,iBAAiB,IAAIxB;IACjD;IACA,OAAOD,WAAWK,MAAM,CAACJ,SAASC,MAAMC;AAC1C;AACAb,MAAMe,MAAM,GAAId,SAAS,IAAIc,SAASL,WAAWK,MAAM;AACvDf,MAAMkB,OAAO,GAAGR,WAAWQ,OAAO"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -30,4 +30,4 @@ function _interop_require_default(obj) {
|
|
|
30
30
|
default: obj
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
33
|
+
/* 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; }
|
|
@@ -28,4 +28,4 @@ function spawnSyncPolyfill(cmd, args, options) {
|
|
|
28
28
|
callbacks: true
|
|
29
29
|
}, workerPath, cmd, args, options || {});
|
|
30
30
|
}
|
|
31
|
-
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (
|
|
31
|
+
/* 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,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ENOENT error handling for Windows
|
|
3
|
+
* 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,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ENOENT error handling for Windows
|
|
3
|
+
* 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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ENOENT error handling for Windows
|
|
3
|
+
* Extracted from cross-spawn v6.0.5
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
function _export(target, all) {
|
|
9
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
_export(exports, {
|
|
15
|
+
get hookChildProcess () {
|
|
16
|
+
return hookChildProcess;
|
|
17
|
+
},
|
|
18
|
+
get notFoundError () {
|
|
19
|
+
return notFoundError;
|
|
20
|
+
},
|
|
21
|
+
get verifyENOENT () {
|
|
22
|
+
return verifyENOENT;
|
|
23
|
+
},
|
|
24
|
+
get verifyENOENTSync () {
|
|
25
|
+
return verifyENOENTSync;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
function _array_like_to_array(arr, len) {
|
|
29
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
30
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
31
|
+
return arr2;
|
|
32
|
+
}
|
|
33
|
+
function _array_without_holes(arr) {
|
|
34
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
35
|
+
}
|
|
36
|
+
function _iterable_to_array(iter) {
|
|
37
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
38
|
+
}
|
|
39
|
+
function _non_iterable_spread() {
|
|
40
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
|
+
}
|
|
42
|
+
function _to_consumable_array(arr) {
|
|
43
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
44
|
+
}
|
|
45
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
46
|
+
if (!o) return;
|
|
47
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
48
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
49
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
50
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
51
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
52
|
+
}
|
|
53
|
+
var isWin = process.platform === 'win32';
|
|
54
|
+
function notFoundError(original, syscall) {
|
|
55
|
+
var err = new Error("".concat(syscall, " ").concat(original.command, " ENOENT"));
|
|
56
|
+
err.code = 'ENOENT';
|
|
57
|
+
err.errno = 'ENOENT';
|
|
58
|
+
err.syscall = "".concat(syscall, " ").concat(original.command);
|
|
59
|
+
err.path = original.command;
|
|
60
|
+
err.spawnargs = original.args;
|
|
61
|
+
return err;
|
|
62
|
+
}
|
|
63
|
+
function hookChildProcess(cp, parsed) {
|
|
64
|
+
if (!isWin) return;
|
|
65
|
+
var originalEmit = cp.emit.bind(cp);
|
|
66
|
+
cp.emit = function(name) {
|
|
67
|
+
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
68
|
+
args[_key - 1] = arguments[_key];
|
|
69
|
+
}
|
|
70
|
+
if (name === 'exit') {
|
|
71
|
+
var err = verifyENOENT(args[0], parsed);
|
|
72
|
+
if (err) {
|
|
73
|
+
return originalEmit('error', err);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return originalEmit.apply(void 0, [
|
|
77
|
+
name
|
|
78
|
+
].concat(_to_consumable_array(args)));
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function verifyENOENT(status, parsed) {
|
|
82
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
83
|
+
return notFoundError(parsed.original, 'spawn');
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
function verifyENOENTSync(status, parsed) {
|
|
88
|
+
if (isWin && status === 1 && !parsed.file) {
|
|
89
|
+
return notFoundError(parsed.original, 'spawnSync');
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
/* 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/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 type { ENOENTError, Parsed } from './types.ts';\n\nconst isWin = process.platform === 'win32';\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 (!isWin) 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 (isWin && 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 (isWin && status === 1 && !parsed.file) {\n return notFoundError(parsed.original, 'spawnSync');\n }\n return null;\n}\n"],"names":["hookChildProcess","notFoundError","verifyENOENT","verifyENOENTSync","isWin","process","platform","original","syscall","err","Error","command","code","errno","path","spawnargs","args","cp","parsed","originalEmit","emit","bind","name","status","file"],"mappings":"AAAA;;;CAGC;;;;;;;;;;;QAiBeA;eAAAA;;QAVAC;eAAAA;;QAyBAC;eAAAA;;QAOAC;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlChB,IAAMC,QAAQC,QAAQC,QAAQ,KAAK;AAE5B,SAASL,cAAcM,QAA4B,EAAEC,OAAe;IACzE,IAAMC,MAAM,IAAIC,MAAM,AAAC,GAAaH,OAAXC,SAAQ,KAAoB,OAAjBD,SAASI,OAAO,EAAC;IACrDF,IAAIG,IAAI,GAAG;IACXH,IAAII,KAAK,GAAG;IACZJ,IAAID,OAAO,GAAG,AAAC,GAAaD,OAAXC,SAAQ,KAAoB,OAAjBD,SAASI,OAAO;IAC5CF,IAAIK,IAAI,GAAGP,SAASI,OAAO;IAC3BF,IAAIM,SAAS,GAAGR,SAASS,IAAI;IAC7B,OAAOP;AACT;AAEO,SAAST,iBAAiBiB,EAAgB,EAAEC,MAAc;IAC/D,IAAI,CAACd,OAAO;IAEZ,IAAMe,eAAeF,GAAGG,IAAI,CAACC,IAAI,CAACJ;IAClCA,GAAGG,IAAI,GAAG,SAACE;yCAA0BN;YAAAA;;QACnC,IAAIM,SAAS,QAAQ;YACnB,IAAMb,MAAMP,aAAac,IAAI,CAAC,EAAE,EAAYE;YAC5C,IAAIT,KAAK;gBACP,OAAOU,aAAa,SAASV;YAC/B;QACF;QACA,OAAOU,mBAAAA,KAAAA,GAAAA;YAAaG;SAAc,CAA3BH,OAAmB,qBAAGH;IAC/B;AACF;AAEO,SAASd,aAAaqB,MAAc,EAAEL,MAAc;IACzD,IAAId,SAASmB,WAAW,KAAK,CAACL,OAAOM,IAAI,EAAE;QACzC,OAAOvB,cAAciB,OAAOX,QAAQ,EAAE;IACxC;IACA,OAAO;AACT;AAEO,SAASJ,iBAAiBoB,MAAc,EAAEL,MAAc;IAC7D,IAAId,SAASmB,WAAW,KAAK,CAACL,OAAOM,IAAI,EAAE;QACzC,OAAOvB,cAAciB,OAAOX,QAAQ,EAAE;IACxC;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get escapeArgument () {
|
|
13
|
+
return escapeArgument;
|
|
14
|
+
},
|
|
15
|
+
get escapeCommand () {
|
|
16
|
+
return escapeCommand;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Windows cmd.exe argument escaping
|
|
21
|
+
* Extracted from cross-spawn v6.0.5
|
|
22
|
+
*/ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
23
|
+
function escapeCommand(arg) {
|
|
24
|
+
return arg.replace(metaCharsRegExp, '^$1');
|
|
25
|
+
}
|
|
26
|
+
function escapeArgument(arg, doubleEscapeMetaChars) {
|
|
27
|
+
// Convert to string
|
|
28
|
+
arg = "".concat(arg);
|
|
29
|
+
// Sequence of backslashes followed by a double quote:
|
|
30
|
+
// double up all the backslashes and escape the double quote
|
|
31
|
+
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
|
|
32
|
+
// Sequence of backslashes followed by the end of the string:
|
|
33
|
+
// double up all the backslashes
|
|
34
|
+
arg = arg.replace(/(\\*)$/, '$1$1');
|
|
35
|
+
// Quote the whole thing
|
|
36
|
+
arg = '"'.concat(arg, '"');
|
|
37
|
+
// Escape meta chars
|
|
38
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
39
|
+
// Double escape meta chars if necessary
|
|
40
|
+
if (doubleEscapeMetaChars) {
|
|
41
|
+
arg = arg.replace(metaCharsRegExp, '^$1');
|
|
42
|
+
}
|
|
43
|
+
return arg;
|
|
44
|
+
}
|
|
45
|
+
/* 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/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":["escapeArgument","escapeCommand","metaCharsRegExp","arg","replace","doubleEscapeMetaChars"],"mappings":";;;;;;;;;;;QAWgBA;eAAAA;;QAJAC;eAAAA;;;AAPhB;;;CAGC,GAED,IAAMC,kBAAkB;AAEjB,SAASD,cAAcE,GAAW;IACvC,OAAOA,IAAIC,OAAO,CAACF,iBAAiB;AACtC;AAEO,SAASF,eAAeG,GAAW,EAAEE,qBAA+B;IACzE,oBAAoB;IACpBF,MAAM,AAAC,GAAM,OAAJA;IAET,sDAAsD;IACtD,4DAA4D;IAC5DA,MAAMA,IAAIC,OAAO,CAAC,WAAW;IAE7B,6DAA6D;IAC7D,gCAAgC;IAChCD,MAAMA,IAAIC,OAAO,CAAC,UAAU;IAE5B,wBAAwB;IACxBD,MAAM,AAAC,IAAO,OAAJA,KAAI;IAEd,oBAAoB;IACpBA,MAAMA,IAAIC,OAAO,CAACF,iBAAiB;IAEnC,wCAAwC;IACxC,IAAIG,uBAAuB;QACzBF,MAAMA,IAAIC,OAAO,CAACF,iBAAiB;IACrC;IAEA,OAAOC;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,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,65 @@
|
|
|
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
|
+
*/ "use strict";
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
function _export(target, all) {
|
|
13
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
_export(exports, {
|
|
19
|
+
get _enoent () {
|
|
20
|
+
return _enoent;
|
|
21
|
+
},
|
|
22
|
+
get _parse () {
|
|
23
|
+
return _parsets.parse;
|
|
24
|
+
},
|
|
25
|
+
get // Main export
|
|
26
|
+
default () {
|
|
27
|
+
return _default;
|
|
28
|
+
},
|
|
29
|
+
get spawn () {
|
|
30
|
+
return spawn;
|
|
31
|
+
},
|
|
32
|
+
get sync () {
|
|
33
|
+
return spawnSync;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _child_process = /*#__PURE__*/ _interop_require_default(require("child_process"));
|
|
37
|
+
var _spawnSyncts = /*#__PURE__*/ _interop_require_default(require("../polyfills/spawnSync.js"));
|
|
38
|
+
var _enoentts = require("./enoent.js");
|
|
39
|
+
var _parsets = require("./parse.js");
|
|
40
|
+
function _interop_require_default(obj) {
|
|
41
|
+
return obj && obj.__esModule ? obj : {
|
|
42
|
+
default: obj
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var cpSpawnSync = _child_process.default.spawnSync || _spawnSyncts.default;
|
|
46
|
+
function spawn(command, args, options) {
|
|
47
|
+
var parsed = (0, _parsets.parse)(command, args, options);
|
|
48
|
+
var spawned = _child_process.default.spawn(parsed.command, parsed.args, parsed.options);
|
|
49
|
+
(0, _enoentts.hookChildProcess)(spawned, parsed);
|
|
50
|
+
return spawned;
|
|
51
|
+
}
|
|
52
|
+
function spawnSync(command, args, options) {
|
|
53
|
+
var parsed = (0, _parsets.parse)(command, args, options);
|
|
54
|
+
var result = cpSpawnSync(parsed.command, parsed.args, parsed.options);
|
|
55
|
+
result.error = result.error || (0, _enoentts.verifyENOENTSync)(result.status, parsed);
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
var _default = spawn;
|
|
59
|
+
var _enoent = {
|
|
60
|
+
hookChildProcess: _enoentts.hookChildProcess,
|
|
61
|
+
verifyENOENT: _enoentts.verifyENOENT,
|
|
62
|
+
verifyENOENTSync: _enoentts.verifyENOENTSync,
|
|
63
|
+
notFoundError: _enoentts.notFoundError
|
|
64
|
+
};
|
|
65
|
+
/* 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/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":["_enoent","_parse","parse","spawn","sync","spawnSync","cpSpawnSync","cp","spawnSyncPolyfill","command","args","options","parsed","spawned","hookChildProcess","result","error","verifyENOENTSync","status","verifyENOENT","notFoundError"],"mappings":"AAAA;;;;;;;CAOC;;;;;;;;;;;QAkCYA;eAAAA;;QADKC;eAATC,cAAK;;QARd,cAAc;IACd;eAAA;;QAGSC;eAAAA;;QACaC;eAAbC;;;oEA3BM;kEACe;wBACkD;uBAC1D;;;;;;AAGtB,IAAMC,cAAcC,sBAAE,CAACF,SAAS,IAAIG,oBAAiB;AAErD,SAASL,MAAMM,OAAe,EAAEC,IAAkC,EAAEC,OAA0B;IAC5F,IAAMC,SAASV,IAAAA,cAAK,EAACO,SAASC,MAAMC;IACpC,IAAME,UAAUN,sBAAE,CAACJ,KAAK,CAACS,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACpEG,IAAAA,0BAAgB,EAACD,SAASD;IAC1B,OAAOC;AACT;AAEA,SAASR,UAAUI,OAAe,EAAEC,IAAkC,EAAEC,OAA0B;IAChG,IAAMC,SAASV,IAAAA,cAAK,EAACO,SAASC,MAAMC;IACpC,IAAMI,SAAST,YAAYM,OAAOH,OAAO,EAAEG,OAAOF,IAAI,EAAEE,OAAOD,OAAO;IACtEI,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIC,IAAAA,0BAAgB,EAACF,OAAOG,MAAM,EAAYN;IACzE,OAAOG;AACT;IAGA,WAAeZ;AAQR,IAAMH,UAAU;IACrBc,kBAAAA,0BAAgB;IAChBK,cAAAA,sBAAY;IACZF,kBAAAA,0BAAgB;IAChBG,eAAAA,uBAAa;AACf"}
|
|
@@ -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,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,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command parsing for cross-platform spawn
|
|
3
|
+
* Simplified from cross-spawn v6.0.5
|
|
4
|
+
*/ "use strict";
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "parse", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function() {
|
|
11
|
+
return parse;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
15
|
+
var _compatts = require("../compat.js");
|
|
16
|
+
var _escapets = require("./escape.js");
|
|
17
|
+
var _resolvets = require("./resolve.js");
|
|
18
|
+
var _shebangts = require("./shebang.js");
|
|
19
|
+
function _interop_require_default(obj) {
|
|
20
|
+
return obj && obj.__esModule ? obj : {
|
|
21
|
+
default: obj
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var isWin = process.platform === 'win32';
|
|
25
|
+
var isExecutableRegExp = /\.(?:com|exe)$/i;
|
|
26
|
+
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
27
|
+
function detectShebang(parsed) {
|
|
28
|
+
parsed.file = (0, _resolvets.resolveCommand)(parsed);
|
|
29
|
+
var shebang = parsed.file && (0, _shebangts.readShebang)(parsed.file);
|
|
30
|
+
if (shebang) {
|
|
31
|
+
parsed.args.unshift(parsed.file);
|
|
32
|
+
parsed.command = shebang;
|
|
33
|
+
return (0, _resolvets.resolveCommand)(parsed);
|
|
34
|
+
}
|
|
35
|
+
return parsed.file;
|
|
36
|
+
}
|
|
37
|
+
function parseNonShell(parsed) {
|
|
38
|
+
if (!isWin) return parsed;
|
|
39
|
+
// Detect & add support for shebangs
|
|
40
|
+
var commandFile = detectShebang(parsed);
|
|
41
|
+
// We don't need a shell if the command filename is an executable
|
|
42
|
+
var needsShell = !isExecutableRegExp.test(commandFile || '');
|
|
43
|
+
if (parsed.options.forceShell || needsShell) {
|
|
44
|
+
// Need to double escape meta chars if the command is a cmd-shim
|
|
45
|
+
var needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile || '');
|
|
46
|
+
// Normalize posix paths into OS compatible paths
|
|
47
|
+
parsed.command = _path.default.normalize(parsed.command);
|
|
48
|
+
// Escape command & arguments
|
|
49
|
+
parsed.command = (0, _escapets.escapeCommand)(parsed.command);
|
|
50
|
+
parsed.args = parsed.args.map(function(arg) {
|
|
51
|
+
return (0, _escapets.escapeArgument)(arg, needsDoubleEscapeMetaChars);
|
|
52
|
+
});
|
|
53
|
+
var shellCommand = [
|
|
54
|
+
parsed.command
|
|
55
|
+
].concat(parsed.args).join(' ');
|
|
56
|
+
parsed.args = [
|
|
57
|
+
'/d',
|
|
58
|
+
'/s',
|
|
59
|
+
'/c',
|
|
60
|
+
'"'.concat(shellCommand, '"')
|
|
61
|
+
];
|
|
62
|
+
parsed.command = process.env.comspec || 'cmd.exe';
|
|
63
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
64
|
+
}
|
|
65
|
+
return parsed;
|
|
66
|
+
}
|
|
67
|
+
function parseShell(parsed) {
|
|
68
|
+
// Mimic node shell option for older Node versions
|
|
69
|
+
var shellCommand = [
|
|
70
|
+
parsed.command
|
|
71
|
+
].concat(parsed.args).join(' ');
|
|
72
|
+
if (isWin) {
|
|
73
|
+
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
|
|
74
|
+
parsed.args = [
|
|
75
|
+
'/d',
|
|
76
|
+
'/s',
|
|
77
|
+
'/c',
|
|
78
|
+
'"'.concat(shellCommand, '"')
|
|
79
|
+
];
|
|
80
|
+
parsed.options.windowsVerbatimArguments = true;
|
|
81
|
+
} else {
|
|
82
|
+
if (typeof parsed.options.shell === 'string') {
|
|
83
|
+
parsed.command = parsed.options.shell;
|
|
84
|
+
} else if (process.platform === 'android') {
|
|
85
|
+
parsed.command = '/system/bin/sh';
|
|
86
|
+
} else {
|
|
87
|
+
parsed.command = '/bin/sh';
|
|
88
|
+
}
|
|
89
|
+
parsed.args = [
|
|
90
|
+
'-c',
|
|
91
|
+
shellCommand
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
return parsed;
|
|
95
|
+
}
|
|
96
|
+
function parse(command, args, options) {
|
|
97
|
+
// Normalize arguments
|
|
98
|
+
var argsArray;
|
|
99
|
+
var opts;
|
|
100
|
+
if (args && !Array.isArray(args)) {
|
|
101
|
+
// args is actually options
|
|
102
|
+
argsArray = [];
|
|
103
|
+
opts = (0, _compatts.objectAssign)({}, args);
|
|
104
|
+
} else {
|
|
105
|
+
argsArray = args ? args.slice(0) : [];
|
|
106
|
+
opts = (0, _compatts.objectAssign)({}, options || {});
|
|
107
|
+
}
|
|
108
|
+
var parsed = {
|
|
109
|
+
command: command,
|
|
110
|
+
args: argsArray,
|
|
111
|
+
options: opts,
|
|
112
|
+
file: undefined,
|
|
113
|
+
original: {
|
|
114
|
+
command: command,
|
|
115
|
+
args: argsArray
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return opts.shell ? parseShell(parsed) : parseNonShell(parsed);
|
|
119
|
+
}
|
|
120
|
+
/* 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/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 { escapeArgument, escapeCommand } from './escape.ts';\nimport { resolveCommand } from './resolve.ts';\nimport { readShebang } from './shebang.ts';\nimport type { Parsed, ShimSpawnOptions } from './types.ts';\n\nconst isWin = process.platform === 'win32';\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 (!isWin) 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 (isWin) {\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":["parse","isWin","process","platform","isExecutableRegExp","isCmdShimRegExp","detectShebang","parsed","file","resolveCommand","shebang","readShebang","args","unshift","command","parseNonShell","commandFile","needsShell","test","options","forceShell","needsDoubleEscapeMetaChars","path","normalize","escapeCommand","map","arg","escapeArgument","shellCommand","concat","join","env","comspec","windowsVerbatimArguments","parseShell","shell","argsArray","opts","Array","isArray","objectAssign","slice","undefined","original"],"mappings":"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"}
|