cross-spawn-cb 1.5.8 → 2.0.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/constants.cjs +19 -0
- package/dist/cjs/constants.cjs.map +1 -0
- package/dist/cjs/{spawn.js → crossSpawn.cjs} +1 -1
- package/dist/cjs/crossSpawn.cjs.map +1 -0
- package/dist/cjs/{spawCompat.js → crossSpawnCompat.cjs} +2 -2
- package/dist/cjs/crossSpawnCompat.cjs.map +1 -0
- package/dist/cjs/{workers/spawnSyncCallback.js → index.cjs} +50 -30
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/{constants.js → types.cjs} +3 -10
- package/dist/cjs/types.cjs.map +1 -0
- package/dist/cjs/workers/{spawnCallback.js → async.cjs} +34 -31
- package/dist/cjs/workers/async.cjs.map +1 -0
- package/dist/cjs/workers/sync.cjs +36 -0
- package/dist/cjs/workers/sync.cjs.map +1 -0
- package/dist/esm/constants.mjs +8 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/crossSpawn.cjs +2 -0
- package/dist/esm/crossSpawn.cjs.map +1 -0
- package/dist/esm/crossSpawnCompat.cjs +34 -0
- package/dist/esm/crossSpawnCompat.cjs.map +1 -0
- package/dist/esm/index.mjs +29 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/polyfills.cjs +16 -0
- package/dist/esm/polyfills.cjs.map +1 -0
- package/dist/esm/types.mjs +1 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/workers/async.mjs +67 -0
- package/dist/esm/workers/async.mjs.map +1 -0
- package/dist/esm/workers/sync.mjs +25 -0
- package/dist/esm/workers/sync.mjs.map +1 -0
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/index.d.ts +16 -0
- package/dist/types/types.d.ts +14 -0
- package/dist/types/workers/async.d.ts +2 -0
- package/dist/types/workers/sync.d.ts +2 -0
- package/package.json +15 -8
- package/assets/package.json +0 -1
- package/dist/cjs/constants.js.map +0 -1
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/spawCompat.js.map +0 -1
- package/dist/cjs/spawn.js.map +0 -1
- package/dist/cjs/workers/spawnCallback.js.map +0 -1
- package/dist/cjs/workers/spawnSyncCallback.js.map +0 -1
- package/dist/types/index.d.cts +0 -9
- package/dist/types/workers/spawnCallback.d.cts +0 -6
- package/dist/types/workers/spawnSyncCallback.d.cts +0 -6
- /package/assets/{cross-spawn.js → cross-spawn.cjs} +0 -0
- /package/dist/cjs/{polyfills.js → polyfills.cjs} +0 -0
- /package/dist/cjs/{polyfills.js.map → polyfills.cjs.map} +0 -0
- /package/dist/types/{spawn.d.cts → crossSpawn.d.cts} +0 -0
- /package/dist/types/{spawCompat.d.cts → crossSpawnCompat.d.cts} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "spawnKeys", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return spawnKeys;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var spawnKeys = [
|
|
12
|
+
'pid',
|
|
13
|
+
'status',
|
|
14
|
+
'signal',
|
|
15
|
+
'stdout',
|
|
16
|
+
'stderr',
|
|
17
|
+
'output'
|
|
18
|
+
];
|
|
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; }
|
|
@@ -0,0 +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":";;;;+BAAaA;;;eAAAA;;;AAAN,IAAMA,YAAY;IAAC;IAAO;IAAU;IAAU;IAAU;IAAU;CAAS"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var major = +process.versions.node.split('.')[0];
|
|
3
|
-
module.exports = major <= 7 ? require('./
|
|
3
|
+
module.exports = major <= 7 ? require('./crossSpawnCompat.cjs') : require('cross-spawn');
|
|
4
4
|
/* 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/crossSpawn.cjs"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\n\nmodule.exports = major <= 7 ? require('./crossSpawnCompat.cjs') : require('cross-spawn');\n"],"names":["major","process","versions","node","split","module","exports","require"],"mappings":";AAAA,IAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElDC,OAAOC,OAAO,GAAGN,SAAS,IAAIO,QAAQ,4BAA4BA,QAAQ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./polyfills.
|
|
2
|
+
require('./polyfills.cjs');
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var cp = require('child_process');
|
|
5
|
-
var spawn_ = require('../../assets/cross-spawn.
|
|
5
|
+
var spawn_ = require('../../assets/cross-spawn.cjs');
|
|
6
6
|
var NODES = [
|
|
7
7
|
'node',
|
|
8
8
|
'node.exe',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/crossSpawnCompat.cjs"],"sourcesContent":["require('./polyfills.cjs');\nconst path = require('path');\nconst cp = require('child_process');\nconst spawn_ = require('../../assets/cross-spawn.cjs');\n\nconst NODES = ['node', 'node.exe', 'node.cmd'];\nfunction parse(command, args, options) {\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;\n }\n return spawn_._parse(command, args, options);\n}\nconst enoent = spawn_._enoent;\n\nfunction spawn(command, args, options) {\n const parsed = parse(command, args, options);\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n enoent.hookChildProcess(spawned, parsed);\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n const parsed = parse(command, args, options);\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n"],"names":["require","path","cp","spawn_","NODES","parse","command","args","options","indexOf","basename","toLowerCase","env","process","NODE","npm_node_execpath","_parse","enoent","_enoent","spawn","parsed","spawned","hookChildProcess","spawnSync","result","error","verifyENOENTSync","status","module","exports","sync"],"mappings":";AAAAA,QAAQ;AACR,IAAMC,OAAOD,QAAQ;AACrB,IAAME,KAAKF,QAAQ;AACnB,IAAMG,SAASH,QAAQ;AAEvB,IAAMI,QAAQ;IAAC;IAAQ;IAAY;CAAW;AAC9C,SAASC,MAAMC,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAIJ,MAAMK,OAAO,CAACR,KAAKS,QAAQ,CAACJ,SAASK,WAAW,OAAO,GAAG;QAC5D,IAAMC,MAAMJ,UAAUA,QAAQI,GAAG,IAAIC,QAAQD,GAAG,GAAGC,QAAQD,GAAG;QAC9DN,UAAUM,IAAIE,IAAI,IAAIF,IAAIG,iBAAiB;IAC7C;IACA,OAAOZ,OAAOa,MAAM,CAACV,SAASC,MAAMC;AACtC;AACA,IAAMS,SAASd,OAAOe,OAAO;AAE7B,SAASC,MAAMb,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,IAAMa,UAAUnB,GAAGiB,KAAK,CAACC,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACpES,OAAOK,gBAAgB,CAACD,SAASD;IACjC,OAAOC;AACT;AAEA,SAASE,UAAUjB,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACvC,IAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,IAAMgB,SAAStB,GAAGqB,SAAS,CAACH,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACvEgB,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIR,OAAOS,gBAAgB,CAACF,OAAOG,MAAM,EAAEP;IACtE,OAAOI;AACT;AAEAI,OAAOC,OAAO,GAAGV;AACjBS,OAAOC,OAAO,CAACV,KAAK,GAAGA;AACvBS,OAAOC,OAAO,CAACC,IAAI,GAAGP;AACtBK,OAAOC,OAAO,CAACb,MAAM,GAAGX;AACxBuB,OAAOC,OAAO,CAACX,OAAO,GAAGD"}
|
|
@@ -1,4 +1,27 @@
|
|
|
1
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: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
crossSpawn: function() {
|
|
13
|
+
return crossSpawn;
|
|
14
|
+
},
|
|
15
|
+
default: function() {
|
|
16
|
+
return spawnCallback;
|
|
17
|
+
},
|
|
18
|
+
sync: function() {
|
|
19
|
+
return sync;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _crossSpawncjs = /*#__PURE__*/ _interop_require_default(require("./crossSpawn.cjs"));
|
|
23
|
+
var _async = /*#__PURE__*/ _interop_require_default(require("./workers/async.cjs"));
|
|
24
|
+
var _sync = /*#__PURE__*/ _interop_require_default(require("./workers/sync.cjs"));
|
|
2
25
|
function _define_property(obj, key, value) {
|
|
3
26
|
if (key in obj) {
|
|
4
27
|
Object.defineProperty(obj, key, {
|
|
@@ -12,6 +35,11 @@ function _define_property(obj, key, value) {
|
|
|
12
35
|
}
|
|
13
36
|
return obj;
|
|
14
37
|
}
|
|
38
|
+
function _interop_require_default(obj) {
|
|
39
|
+
return obj && obj.__esModule ? obj : {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
15
43
|
function _object_spread(target) {
|
|
16
44
|
for(var i = 1; i < arguments.length; i++){
|
|
17
45
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -51,41 +79,33 @@ function _object_spread_props(target, source) {
|
|
|
51
79
|
}
|
|
52
80
|
return target;
|
|
53
81
|
}
|
|
54
|
-
|
|
55
|
-
var spawn = require('../spawn.js');
|
|
56
|
-
function worker(res, options) {
|
|
57
|
-
// pipe if inherited
|
|
58
|
-
if (res.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {
|
|
59
|
-
process.stdout.write(res.stdout);
|
|
60
|
-
res.stdout = null;
|
|
61
|
-
}
|
|
62
|
-
if (res.stderr && (options.stderr === 'inherit' || options.stdio === 'inherit')) {
|
|
63
|
-
process.stderr.write(res.stderr);
|
|
64
|
-
res.stderr = null;
|
|
65
|
-
}
|
|
66
|
-
// patch: early node on windows could return null
|
|
67
|
-
if (res.status === null) res.status = 0;
|
|
68
|
-
// process errors
|
|
69
|
-
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
70
|
-
if (err) {
|
|
71
|
-
for(var key in res){
|
|
72
|
-
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
73
|
-
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
if (err) throw err;
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
function spawnCallbackSync(command, args, options) {
|
|
82
|
+
function sync(command, args, options) {
|
|
80
83
|
options = options || {};
|
|
81
84
|
var syncOptions = _object_spread_props(_object_spread({}, options), {
|
|
82
85
|
env: options.env || process.env,
|
|
83
86
|
stdio: 'pipe',
|
|
84
87
|
encoding: 'utf8'
|
|
85
88
|
});
|
|
86
|
-
var res =
|
|
87
|
-
return
|
|
89
|
+
var res = _crossSpawncjs.default.sync(command, args, syncOptions);
|
|
90
|
+
return (0, _sync.default)(res, options);
|
|
91
|
+
}
|
|
92
|
+
sync.worker = _sync.default;
|
|
93
|
+
function spawnCallback(command, args, options, callback) {
|
|
94
|
+
if (typeof options === 'function') {
|
|
95
|
+
callback = options;
|
|
96
|
+
options = {};
|
|
97
|
+
}
|
|
98
|
+
options = options || {};
|
|
99
|
+
var cp = (0, _crossSpawncjs.default)(command, args, options);
|
|
100
|
+
if (typeof callback === 'function') return (0, _async.default)(cp, options, callback);
|
|
101
|
+
return new Promise(function(resolve, reject) {
|
|
102
|
+
return (0, _async.default)(cp, options, function(err, res) {
|
|
103
|
+
return err ? reject(err) : resolve(res);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
88
106
|
}
|
|
89
|
-
|
|
90
|
-
|
|
107
|
+
spawnCallback.worker = _async.default;
|
|
108
|
+
spawnCallback.sync = sync;
|
|
109
|
+
spawnCallback.crossSpawn = _crossSpawncjs.default;
|
|
110
|
+
var crossSpawn = _crossSpawncjs.default;
|
|
91
111
|
/* 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/index.ts"],"sourcesContent":["import crossSpawn_ from './crossSpawn.cjs';\n\nimport asyncWorker from './workers/async';\nimport syncWorker from './workers/sync';\n\nexport type * from './types';\n\nexport function sync(command: string, args: string[], options?: SpawnOptions): SpawnResult {\n options = options || {};\n const syncOptions = { ...options, env: options.env || process.env, stdio: 'pipe', encoding: 'utf8' };\n const res = crossSpawn_.sync(command, args, syncOptions);\n return syncWorker(res, options as SpawnOptions);\n}\nsync.worker = syncWorker;\n\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types';\nexport default function spawnCallback(command: string, args: string[], options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): undefined | Promise<SpawnResult> {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n const cp = crossSpawn_(command, args, options);\n\n if (typeof callback === 'function') return asyncWorker(cp, options, callback) as undefined;\n return new Promise((resolve, reject) => asyncWorker(cp, options, (err, res) => (err ? reject(err) : resolve(res))));\n}\nspawnCallback.worker = asyncWorker;\nspawnCallback.sync = sync;\nspawnCallback.crossSpawn = crossSpawn_;\n\nexport const crossSpawn = crossSpawn_;\n"],"names":["crossSpawn","spawnCallback","sync","command","args","options","syncOptions","env","process","stdio","encoding","res","crossSpawn_","syncWorker","worker","callback","cp","asyncWorker","Promise","resolve","reject","err"],"mappings":";;;;;;;;;;;IA+BaA,UAAU;eAAVA;;IAfb,OAUC;eAVuBC;;IATRC,IAAI;eAAJA;;;oEAPQ;4DAEA;2DACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIhB,SAASA,KAAKC,OAAe,EAAEC,IAAc,EAAEC,OAAsB;IAC1EA,UAAUA,WAAW,CAAC;IACtB,IAAMC,cAAc,wCAAKD;QAASE,KAAKF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;QAAEE,OAAO;QAAQC,UAAU;;IAC5F,IAAMC,MAAMC,sBAAW,CAACV,IAAI,CAACC,SAASC,MAAME;IAC5C,OAAOO,IAAAA,aAAU,EAACF,KAAKN;AACzB;AACAH,KAAKY,MAAM,GAAGD,aAAU;AAGT,SAASZ,cAAcE,OAAe,EAAEC,IAAc,EAAEC,OAAsC,EAAEU,QAAwB;IACrI,IAAI,OAAOV,YAAY,YAAY;QACjCU,WAAWV;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtB,IAAMW,KAAKJ,IAAAA,sBAAW,EAACT,SAASC,MAAMC;IAEtC,IAAI,OAAOU,aAAa,YAAY,OAAOE,IAAAA,cAAW,EAACD,IAAIX,SAASU;IACpE,OAAO,IAAIG,QAAQ,SAACC,SAASC;eAAWH,IAAAA,cAAW,EAACD,IAAIX,SAAS,SAACgB,KAAKV;mBAASU,MAAMD,OAAOC,OAAOF,QAAQR;;;AAC9G;AACAV,cAAca,MAAM,GAAGG,cAAW;AAClChB,cAAcC,IAAI,GAAGA;AACrBD,cAAcD,UAAU,GAAGY,sBAAW;AAE/B,IAAMZ,aAAaY,sBAAW"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
'status',
|
|
6
|
-
'signal',
|
|
7
|
-
'stdout',
|
|
8
|
-
'stderr',
|
|
9
|
-
'output'
|
|
10
|
-
]
|
|
11
|
-
};
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
12
5
|
/* 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":[],"names":[],"mappings":""}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return worker;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _calloncefn = /*#__PURE__*/ _interop_require_default(require("call-once-fn"));
|
|
12
|
+
var _nexttick = /*#__PURE__*/ _interop_require_default(require("next-tick"));
|
|
13
|
+
var _constants = require("../constants.cjs");
|
|
14
|
+
function _interop_require_default(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
6
19
|
function worker(cp, options, callback) {
|
|
7
20
|
if (typeof options === 'function') {
|
|
8
21
|
callback = options;
|
|
9
22
|
options = {};
|
|
10
23
|
}
|
|
11
24
|
options = options || {};
|
|
12
|
-
callback =
|
|
25
|
+
callback = (0, _calloncefn.default)(callback);
|
|
26
|
+
var stdout = null;
|
|
27
|
+
var stderr = null;
|
|
13
28
|
// collect output
|
|
14
29
|
var res = {
|
|
15
30
|
stdout: null,
|
|
@@ -17,32 +32,32 @@ function worker(cp, options, callback) {
|
|
|
17
32
|
};
|
|
18
33
|
if (options.encoding) {
|
|
19
34
|
if (cp.stdout) {
|
|
20
|
-
|
|
21
|
-
cp.stdout.on('data',
|
|
35
|
+
stdout = [];
|
|
36
|
+
cp.stdout.on('data', stdout.push.bind(stdout));
|
|
22
37
|
}
|
|
23
38
|
if (cp.stderr) {
|
|
24
|
-
|
|
25
|
-
cp.stderr.on('data',
|
|
39
|
+
stderr = [];
|
|
40
|
+
cp.stderr.on('data', stderr.push.bind(stderr));
|
|
26
41
|
}
|
|
27
42
|
}
|
|
28
43
|
// some versions of node emit both an error and close
|
|
29
|
-
cp.on('error', function
|
|
30
|
-
err.code === 'OK' || callback(err);
|
|
44
|
+
cp.on('error', function(err) {
|
|
45
|
+
return err.code === 'OK' || callback(err);
|
|
31
46
|
});
|
|
32
47
|
// done
|
|
33
48
|
cp.on('close', function(status, signal) {
|
|
34
|
-
|
|
49
|
+
(0, _nexttick.default)(function closeNextTick() {
|
|
35
50
|
// prepare result
|
|
36
51
|
res.pid = cp.pid;
|
|
37
52
|
res.status = status;
|
|
38
53
|
res.signal = signal;
|
|
39
|
-
if (
|
|
40
|
-
res.stdout = Buffer.concat(
|
|
41
|
-
if (options.encoding !== '
|
|
54
|
+
if (stdout) {
|
|
55
|
+
res.stdout = Buffer.concat(stdout);
|
|
56
|
+
if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);
|
|
42
57
|
}
|
|
43
|
-
if (
|
|
44
|
-
res.stderr = Buffer.concat(
|
|
45
|
-
if (options.encoding !== '
|
|
58
|
+
if (stderr) {
|
|
59
|
+
res.stderr = Buffer.concat(stderr);
|
|
60
|
+
if (options.encoding !== 'binary') res.stderr = res.stderr.toString(options.encoding);
|
|
46
61
|
}
|
|
47
62
|
res.output = [
|
|
48
63
|
null,
|
|
@@ -55,7 +70,7 @@ function worker(cp, options, callback) {
|
|
|
55
70
|
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
56
71
|
if (err) {
|
|
57
72
|
for(var key in res){
|
|
58
|
-
if (
|
|
73
|
+
if (_constants.spawnKeys.indexOf(key) < 0) continue;
|
|
59
74
|
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
60
75
|
}
|
|
61
76
|
}
|
|
@@ -67,16 +82,4 @@ function worker(cp, options, callback) {
|
|
|
67
82
|
cp.stdin.end(options.input);
|
|
68
83
|
}
|
|
69
84
|
}
|
|
70
|
-
function spawnCallback(command, args, options, callback) {
|
|
71
|
-
if (typeof options === 'function') {
|
|
72
|
-
callback = options;
|
|
73
|
-
options = {};
|
|
74
|
-
}
|
|
75
|
-
options = options || {};
|
|
76
|
-
callback = once(callback);
|
|
77
|
-
var cp = spawn(command, args, options);
|
|
78
|
-
return worker(cp, options, callback);
|
|
79
|
-
}
|
|
80
|
-
module.exports = spawnCallback;
|
|
81
|
-
module.exports.worker = worker;
|
|
82
85
|
/* 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/workers/async.ts"],"sourcesContent":["import once from 'call-once-fn';\nimport nextTick from 'next-tick';\nimport { spawnKeys } from '../constants';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types';\n\nexport default function worker(cp: ChildProcess, options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = once(callback);\n let stdout: Buffer[] = null;\n let stderr: Buffer[] = null;\n\n // collect output\n const res = { stdout: null, stderr: null } as SpawnResult;\n if (options.encoding) {\n if (cp.stdout) {\n stdout = [];\n cp.stdout.on('data', stdout.push.bind(stdout));\n }\n if (cp.stderr) {\n stderr = [];\n cp.stderr.on('data', stderr.push.bind(stderr));\n }\n }\n\n // some versions of node emit both an error and close\n cp.on('error', (err: SpawnError) => err.code === 'OK' || callback(err));\n\n // done\n cp.on('close', (status, signal) => {\n nextTick(function closeNextTick() {\n // prepare result\n res.pid = cp.pid;\n res.status = status;\n res.signal = signal;\n if (stdout) {\n res.stdout = Buffer.concat(stdout);\n if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);\n }\n if (stderr) {\n res.stderr = Buffer.concat(stderr);\n if (options.encoding !== 'binary') res.stderr = res.stderr.toString(options.encoding);\n }\n res.output = [null, res.stdout, res.stderr];\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n err ? callback(err) : callback(null, res);\n });\n });\n\n // pipe input\n if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {\n cp.stdin.end(options.input);\n }\n}\n"],"names":["worker","cp","options","callback","once","stdout","stderr","res","encoding","on","push","bind","err","code","status","signal","nextTick","closeNextTick","pid","Buffer","concat","toString","output","Error","key","spawnKeys","indexOf","isBuffer","input","stdin","end"],"mappings":";;;;+BAMA;;;eAAwBA;;;iEANP;+DACI;yBACK;;;;;;AAIX,SAASA,OAAOC,EAAgB,EAAEC,OAAsC,EAAEC,QAAwB;IAC/G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWC,IAAAA,mBAAI,EAACD;IAChB,IAAIE,SAAmB;IACvB,IAAIC,SAAmB;IAEvB,iBAAiB;IACjB,IAAMC,MAAM;QAAEF,QAAQ;QAAMC,QAAQ;IAAK;IACzC,IAAIJ,QAAQM,QAAQ,EAAE;QACpB,IAAIP,GAAGI,MAAM,EAAE;YACbA,SAAS,EAAE;YACXJ,GAAGI,MAAM,CAACI,EAAE,CAAC,QAAQJ,OAAOK,IAAI,CAACC,IAAI,CAACN;QACxC;QACA,IAAIJ,GAAGK,MAAM,EAAE;YACbA,SAAS,EAAE;YACXL,GAAGK,MAAM,CAACG,EAAE,CAAC,QAAQH,OAAOI,IAAI,CAACC,IAAI,CAACL;QACxC;IACF;IAEA,qDAAqD;IACrDL,GAAGQ,EAAE,CAAC,SAAS,SAACG;eAAoBA,IAAIC,IAAI,KAAK,QAAQV,SAASS;;IAElE,OAAO;IACPX,GAAGQ,EAAE,CAAC,SAAS,SAACK,QAAQC;QACtBC,IAAAA,iBAAQ,EAAC,SAASC;YAChB,iBAAiB;YACjBV,IAAIW,GAAG,GAAGjB,GAAGiB,GAAG;YAChBX,IAAIO,MAAM,GAAGA;YACbP,IAAIQ,MAAM,GAAGA;YACb,IAAIV,QAAQ;gBACVE,IAAIF,MAAM,GAAGc,OAAOC,MAAM,CAACf;gBAC3B,IAAIH,QAAQM,QAAQ,KAAK,UAAUD,IAAIF,MAAM,GAAGE,IAAIF,MAAM,CAACgB,QAAQ,CAACnB,QAAQM,QAAQ;YACtF;YACA,IAAIF,QAAQ;gBACVC,IAAID,MAAM,GAAGa,OAAOC,MAAM,CAACd;gBAC3B,IAAIJ,QAAQM,QAAQ,KAAK,UAAUD,IAAID,MAAM,GAAGC,IAAID,MAAM,CAACe,QAAQ,CAACnB,QAAQM,QAAQ;YACtF;YACAD,IAAIe,MAAM,GAAG;gBAAC;gBAAMf,IAAIF,MAAM;gBAAEE,IAAID,MAAM;aAAC;YAE3C,iDAAiD;YACjD,IAAIC,IAAIO,MAAM,KAAK,MAAMP,IAAIO,MAAM,GAAG;YAEtC,iBAAiB;YACjB,IAAMF,MAAML,IAAIO,MAAM,KAAK,IAAI,IAAIS,MAAM,AAAC,uBAAiC,OAAXhB,IAAIO,MAAM,KAAM;YAChF,IAAIF,KAAK;gBACP,IAAK,IAAMY,OAAOjB,IAAK;oBACrB,IAAIkB,oBAAS,CAACC,OAAO,CAACF,OAAO,GAAG;oBAChCZ,GAAG,CAACY,IAAI,GAAGL,OAAOQ,QAAQ,CAACpB,GAAG,CAACiB,IAAI,IAAIjB,GAAG,CAACiB,IAAI,CAACH,QAAQ,CAAC,UAAUd,GAAG,CAACiB,IAAI;gBAC7E;YACF;YACAZ,MAAMT,SAASS,OAAOT,SAAS,MAAMI;QACvC;IACF;IAEA,aAAa;IACb,IAAIL,QAAQ0B,KAAK,IAAK,CAAA,OAAO1B,QAAQ0B,KAAK,KAAK,YAAYT,OAAOQ,QAAQ,CAACzB,QAAQ0B,KAAK,CAAA,GAAI;QAC1F3B,GAAG4B,KAAK,CAACC,GAAG,CAAC5B,QAAQ0B,KAAK;IAC5B;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return worker;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _constants = require("../constants.cjs");
|
|
12
|
+
function worker(res, options) {
|
|
13
|
+
options = options || {};
|
|
14
|
+
// pipe if inherited
|
|
15
|
+
if (res.stdout && options.stdio === 'inherit') {
|
|
16
|
+
process.stdout.write(res.stdout);
|
|
17
|
+
res.stdout = null;
|
|
18
|
+
}
|
|
19
|
+
if (res.stderr && options.stdio === 'inherit') {
|
|
20
|
+
process.stderr.write(res.stderr);
|
|
21
|
+
res.stderr = null;
|
|
22
|
+
}
|
|
23
|
+
// patch: early node on windows could return null
|
|
24
|
+
if (res.status === null) res.status = 0;
|
|
25
|
+
// process errors
|
|
26
|
+
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
27
|
+
if (err) {
|
|
28
|
+
for(var key in res){
|
|
29
|
+
if (_constants.spawnKeys.indexOf(key) < 0) continue;
|
|
30
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (err) throw err;
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
/* 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/workers/sync.ts"],"sourcesContent":["import { spawnKeys } from '../constants';\n\nimport type { SpawnOptions, SpawnResult } from '../types';\n\nexport default function worker(res: SpawnResult, options?: SpawnOptions) {\n options = options || {};\n\n // pipe if inherited\n if (res.stdout && options.stdio === 'inherit') {\n process.stdout.write(res.stdout);\n res.stdout = null;\n }\n if (res.stderr && options.stdio === 'inherit') {\n process.stderr.write(res.stderr);\n res.stderr = null;\n }\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n if (err) throw err;\n return res;\n}\n"],"names":["worker","res","options","stdout","stdio","process","write","stderr","status","err","Error","key","spawnKeys","indexOf","Buffer","isBuffer","toString"],"mappings":";;;;+BAIA;;;eAAwBA;;;yBAJE;AAIX,SAASA,OAAOC,GAAgB,EAAEC,OAAsB;IACrEA,UAAUA,WAAW,CAAC;IAEtB,oBAAoB;IACpB,IAAID,IAAIE,MAAM,IAAID,QAAQE,KAAK,KAAK,WAAW;QAC7CC,QAAQF,MAAM,CAACG,KAAK,CAACL,IAAIE,MAAM;QAC/BF,IAAIE,MAAM,GAAG;IACf;IACA,IAAIF,IAAIM,MAAM,IAAIL,QAAQE,KAAK,KAAK,WAAW;QAC7CC,QAAQE,MAAM,CAACD,KAAK,CAACL,IAAIM,MAAM;QAC/BN,IAAIM,MAAM,GAAG;IACf;IAEA,iDAAiD;IACjD,IAAIN,IAAIO,MAAM,KAAK,MAAMP,IAAIO,MAAM,GAAG;IAEtC,iBAAiB;IACjB,IAAMC,MAAMR,IAAIO,MAAM,KAAK,IAAI,IAAIE,MAAM,AAAC,uBAAiC,OAAXT,IAAIO,MAAM,KAAM;IAChF,IAAIC,KAAK;QACP,IAAK,IAAME,OAAOV,IAAK;YACrB,IAAIW,oBAAS,CAACC,OAAO,CAACF,OAAO,GAAG;YAChCF,GAAG,CAACE,IAAI,GAAGG,OAAOC,QAAQ,CAACd,GAAG,CAACU,IAAI,IAAIV,GAAG,CAACU,IAAI,CAACK,QAAQ,CAAC,UAAUf,GAAG,CAACU,IAAI;QAC7E;IACF;IACA,IAAIF,KAAK,MAAMA;IACf,OAAOR;AACT"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/crossSpawn.cjs"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\n\nmodule.exports = major <= 7 ? require('./crossSpawnCompat.cjs') : require('cross-spawn');\n"],"names":["major","process","versions","node","split","module","exports","require"],"mappings":"AAAA,MAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElDC,OAAOC,OAAO,GAAGN,SAAS,IAAIO,QAAQ,4BAA4BA,QAAQ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require('./polyfills.cjs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const cp = require('child_process');
|
|
4
|
+
const spawn_ = require('../../assets/cross-spawn.cjs');
|
|
5
|
+
const NODES = [
|
|
6
|
+
'node',
|
|
7
|
+
'node.exe',
|
|
8
|
+
'node.cmd'
|
|
9
|
+
];
|
|
10
|
+
function parse(command, args, options) {
|
|
11
|
+
if (NODES.indexOf(path.basename(command).toLowerCase()) >= 0) {
|
|
12
|
+
const env = options ? options.env || process.env : process.env;
|
|
13
|
+
command = env.NODE || env.npm_node_execpath;
|
|
14
|
+
}
|
|
15
|
+
return spawn_._parse(command, args, options);
|
|
16
|
+
}
|
|
17
|
+
const enoent = spawn_._enoent;
|
|
18
|
+
function spawn(command, args, options) {
|
|
19
|
+
const parsed = parse(command, args, options);
|
|
20
|
+
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
21
|
+
enoent.hookChildProcess(spawned, parsed);
|
|
22
|
+
return spawned;
|
|
23
|
+
}
|
|
24
|
+
function spawnSync(command, args, options) {
|
|
25
|
+
const parsed = parse(command, args, options);
|
|
26
|
+
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
27
|
+
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
module.exports = spawn;
|
|
31
|
+
module.exports.spawn = spawn;
|
|
32
|
+
module.exports.sync = spawnSync;
|
|
33
|
+
module.exports._parse = parse;
|
|
34
|
+
module.exports._enoent = enoent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/crossSpawnCompat.cjs"],"sourcesContent":["require('./polyfills.cjs');\nconst path = require('path');\nconst cp = require('child_process');\nconst spawn_ = require('../../assets/cross-spawn.cjs');\n\nconst NODES = ['node', 'node.exe', 'node.cmd'];\nfunction parse(command, args, options) {\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;\n }\n return spawn_._parse(command, args, options);\n}\nconst enoent = spawn_._enoent;\n\nfunction spawn(command, args, options) {\n const parsed = parse(command, args, options);\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n enoent.hookChildProcess(spawned, parsed);\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n const parsed = parse(command, args, options);\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n"],"names":["require","path","cp","spawn_","NODES","parse","command","args","options","indexOf","basename","toLowerCase","env","process","NODE","npm_node_execpath","_parse","enoent","_enoent","spawn","parsed","spawned","hookChildProcess","spawnSync","result","error","verifyENOENTSync","status","module","exports","sync"],"mappings":"AAAAA,QAAQ;AACR,MAAMC,OAAOD,QAAQ;AACrB,MAAME,KAAKF,QAAQ;AACnB,MAAMG,SAASH,QAAQ;AAEvB,MAAMI,QAAQ;IAAC;IAAQ;IAAY;CAAW;AAC9C,SAASC,MAAMC,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAIJ,MAAMK,OAAO,CAACR,KAAKS,QAAQ,CAACJ,SAASK,WAAW,OAAO,GAAG;QAC5D,MAAMC,MAAMJ,UAAUA,QAAQI,GAAG,IAAIC,QAAQD,GAAG,GAAGC,QAAQD,GAAG;QAC9DN,UAAUM,IAAIE,IAAI,IAAIF,IAAIG,iBAAiB;IAC7C;IACA,OAAOZ,OAAOa,MAAM,CAACV,SAASC,MAAMC;AACtC;AACA,MAAMS,SAASd,OAAOe,OAAO;AAE7B,SAASC,MAAMb,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,MAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,MAAMa,UAAUnB,GAAGiB,KAAK,CAACC,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACpES,OAAOK,gBAAgB,CAACD,SAASD;IACjC,OAAOC;AACT;AAEA,SAASE,UAAUjB,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACvC,MAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,MAAMgB,SAAStB,GAAGqB,SAAS,CAACH,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACvEgB,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIR,OAAOS,gBAAgB,CAACF,OAAOG,MAAM,EAAEP;IACtE,OAAOI;AACT;AAEAI,OAAOC,OAAO,GAAGV;AACjBS,OAAOC,OAAO,CAACV,KAAK,GAAGA;AACvBS,OAAOC,OAAO,CAACC,IAAI,GAAGP;AACtBK,OAAOC,OAAO,CAACb,MAAM,GAAGX;AACxBuB,OAAOC,OAAO,CAACX,OAAO,GAAGD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import crossSpawn_ from './crossSpawn.cjs';
|
|
2
|
+
import asyncWorker from './workers/async.mjs';
|
|
3
|
+
import syncWorker from './workers/sync.mjs';
|
|
4
|
+
export function sync(command, args, options) {
|
|
5
|
+
options = options || {};
|
|
6
|
+
const syncOptions = {
|
|
7
|
+
...options,
|
|
8
|
+
env: options.env || process.env,
|
|
9
|
+
stdio: 'pipe',
|
|
10
|
+
encoding: 'utf8'
|
|
11
|
+
};
|
|
12
|
+
const res = crossSpawn_.sync(command, args, syncOptions);
|
|
13
|
+
return syncWorker(res, options);
|
|
14
|
+
}
|
|
15
|
+
sync.worker = syncWorker;
|
|
16
|
+
export default function spawnCallback(command, args, options, callback) {
|
|
17
|
+
if (typeof options === 'function') {
|
|
18
|
+
callback = options;
|
|
19
|
+
options = {};
|
|
20
|
+
}
|
|
21
|
+
options = options || {};
|
|
22
|
+
const cp = crossSpawn_(command, args, options);
|
|
23
|
+
if (typeof callback === 'function') return asyncWorker(cp, options, callback);
|
|
24
|
+
return new Promise((resolve, reject)=>asyncWorker(cp, options, (err, res)=>err ? reject(err) : resolve(res)));
|
|
25
|
+
}
|
|
26
|
+
spawnCallback.worker = asyncWorker;
|
|
27
|
+
spawnCallback.sync = sync;
|
|
28
|
+
spawnCallback.crossSpawn = crossSpawn_;
|
|
29
|
+
export const crossSpawn = crossSpawn_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/index.ts"],"sourcesContent":["import crossSpawn_ from './crossSpawn.cjs';\n\nimport asyncWorker from './workers/async';\nimport syncWorker from './workers/sync';\n\nexport type * from './types';\n\nexport function sync(command: string, args: string[], options?: SpawnOptions): SpawnResult {\n options = options || {};\n const syncOptions = { ...options, env: options.env || process.env, stdio: 'pipe', encoding: 'utf8' };\n const res = crossSpawn_.sync(command, args, syncOptions);\n return syncWorker(res, options as SpawnOptions);\n}\nsync.worker = syncWorker;\n\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types';\nexport default function spawnCallback(command: string, args: string[], options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): undefined | Promise<SpawnResult> {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n const cp = crossSpawn_(command, args, options);\n\n if (typeof callback === 'function') return asyncWorker(cp, options, callback) as undefined;\n return new Promise((resolve, reject) => asyncWorker(cp, options, (err, res) => (err ? reject(err) : resolve(res))));\n}\nspawnCallback.worker = asyncWorker;\nspawnCallback.sync = sync;\nspawnCallback.crossSpawn = crossSpawn_;\n\nexport const crossSpawn = crossSpawn_;\n"],"names":["crossSpawn_","asyncWorker","syncWorker","sync","command","args","options","syncOptions","env","process","stdio","encoding","res","worker","spawnCallback","callback","cp","Promise","resolve","reject","err","crossSpawn"],"mappings":"AAAA,OAAOA,iBAAiB,mBAAmB;AAE3C,OAAOC,iBAAiB,kBAAkB;AAC1C,OAAOC,gBAAgB,iBAAiB;AAIxC,OAAO,SAASC,KAAKC,OAAe,EAAEC,IAAc,EAAEC,OAAsB;IAC1EA,UAAUA,WAAW,CAAC;IACtB,MAAMC,cAAc;QAAE,GAAGD,OAAO;QAAEE,KAAKF,QAAQE,GAAG,IAAIC,QAAQD,GAAG;QAAEE,OAAO;QAAQC,UAAU;IAAO;IACnG,MAAMC,MAAMZ,YAAYG,IAAI,CAACC,SAASC,MAAME;IAC5C,OAAOL,WAAWU,KAAKN;AACzB;AACAH,KAAKU,MAAM,GAAGX;AAGd,eAAe,SAASY,cAAcV,OAAe,EAAEC,IAAc,EAAEC,OAAsC,EAAES,QAAwB;IACrI,IAAI,OAAOT,YAAY,YAAY;QACjCS,WAAWT;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtB,MAAMU,KAAKhB,YAAYI,SAASC,MAAMC;IAEtC,IAAI,OAAOS,aAAa,YAAY,OAAOd,YAAYe,IAAIV,SAASS;IACpE,OAAO,IAAIE,QAAQ,CAACC,SAASC,SAAWlB,YAAYe,IAAIV,SAAS,CAACc,KAAKR,MAASQ,MAAMD,OAAOC,OAAOF,QAAQN;AAC9G;AACAE,cAAcD,MAAM,GAAGZ;AACvBa,cAAcX,IAAI,GAAGA;AACrBW,cAAcO,UAAU,GAAGrB;AAE3B,OAAO,MAAMqB,aAAarB,YAAY"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require('core-js/actual/object/keys');
|
|
2
|
+
require('core-js/actual/array/find');
|
|
3
|
+
require('buffer-v6-polyfill');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
if (!path.delimiter) path.delimiter = process.platform === 'win32' ? ';' : ':';
|
|
6
|
+
const cp = require('child_process');
|
|
7
|
+
if (!cp.spawnSync) {
|
|
8
|
+
const spawnCallback = path.join(__dirname, 'workers', 'spawnCallback.js');
|
|
9
|
+
let functionExec = null; // break dependencies
|
|
10
|
+
cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {
|
|
11
|
+
if (!functionExec) functionExec = require('function-exec-sync');
|
|
12
|
+
return functionExec({
|
|
13
|
+
callbacks: true
|
|
14
|
+
}, spawnCallback, cmd, args, options || {});
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/polyfills.cjs"],"sourcesContent":["require('core-js/actual/object/keys');\nrequire('core-js/actual/array/find');\nrequire('buffer-v6-polyfill');\n\nconst path = require('path');\nif (!path.delimiter) path.delimiter = process.platform === 'win32' ? ';' : ':';\n\nconst cp = require('child_process');\nif (!cp.spawnSync) {\n const spawnCallback = path.join(__dirname, 'workers', 'spawnCallback.js');\n\n let functionExec = null; // break dependencies\n cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {\n if (!functionExec) functionExec = require('function-exec-sync');\n\n return functionExec({ callbacks: true }, spawnCallback, cmd, args, options || {});\n };\n}\n"],"names":["require","path","delimiter","process","platform","cp","spawnSync","spawnCallback","join","__dirname","functionExec","spawnSyncPolyfill","cmd","args","options","callbacks"],"mappings":"AAAAA,QAAQ;AACRA,QAAQ;AACRA,QAAQ;AAER,MAAMC,OAAOD,QAAQ;AACrB,IAAI,CAACC,KAAKC,SAAS,EAAED,KAAKC,SAAS,GAAGC,QAAQC,QAAQ,KAAK,UAAU,MAAM;AAE3E,MAAMC,KAAKL,QAAQ;AACnB,IAAI,CAACK,GAAGC,SAAS,EAAE;IACjB,MAAMC,gBAAgBN,KAAKO,IAAI,CAACC,WAAW,WAAW;IAEtD,IAAIC,eAAe,MAAM,qBAAqB;IAC9CL,GAAGC,SAAS,GAAG,SAASK,kBAAkBC,GAAG,EAAEC,IAAI,EAAEC,OAAO;QAC1D,IAAI,CAACJ,cAAcA,eAAeV,QAAQ;QAE1C,OAAOU,aAAa;YAAEK,WAAW;QAAK,GAAGR,eAAeK,KAAKC,MAAMC,WAAW,CAAC;IACjF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/types.ts"],"sourcesContent":["import type { SpawnOptions as SpawnOptionsBase, SpawnSyncReturns } from 'child_process';\n\nexport type { ChildProcess } from 'child_process';\nexport interface SpawnOptions extends SpawnOptionsBase {\n encoding?: BufferEncoding;\n env?: NodeJS.ProcessEnv;\n input?: string | Buffer;\n}\nexport type SpawnResult = SpawnSyncReturns<string | Buffer>;\n\nexport interface SpawnError extends Error {\n status?: number;\n stderr?: string | Buffer;\n code?: string;\n}\nexport type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;\n"],"names":[],"mappings":"AAeA,WAA0E"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import once from 'call-once-fn';
|
|
2
|
+
import nextTick from 'next-tick';
|
|
3
|
+
import { spawnKeys } from '../constants.mjs';
|
|
4
|
+
export default function worker(cp, options, callback) {
|
|
5
|
+
if (typeof options === 'function') {
|
|
6
|
+
callback = options;
|
|
7
|
+
options = {};
|
|
8
|
+
}
|
|
9
|
+
options = options || {};
|
|
10
|
+
callback = once(callback);
|
|
11
|
+
let stdout = null;
|
|
12
|
+
let stderr = null;
|
|
13
|
+
// collect output
|
|
14
|
+
const res = {
|
|
15
|
+
stdout: null,
|
|
16
|
+
stderr: null
|
|
17
|
+
};
|
|
18
|
+
if (options.encoding) {
|
|
19
|
+
if (cp.stdout) {
|
|
20
|
+
stdout = [];
|
|
21
|
+
cp.stdout.on('data', stdout.push.bind(stdout));
|
|
22
|
+
}
|
|
23
|
+
if (cp.stderr) {
|
|
24
|
+
stderr = [];
|
|
25
|
+
cp.stderr.on('data', stderr.push.bind(stderr));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// some versions of node emit both an error and close
|
|
29
|
+
cp.on('error', (err)=>err.code === 'OK' || callback(err));
|
|
30
|
+
// done
|
|
31
|
+
cp.on('close', (status, signal)=>{
|
|
32
|
+
nextTick(function closeNextTick() {
|
|
33
|
+
// prepare result
|
|
34
|
+
res.pid = cp.pid;
|
|
35
|
+
res.status = status;
|
|
36
|
+
res.signal = signal;
|
|
37
|
+
if (stdout) {
|
|
38
|
+
res.stdout = Buffer.concat(stdout);
|
|
39
|
+
if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);
|
|
40
|
+
}
|
|
41
|
+
if (stderr) {
|
|
42
|
+
res.stderr = Buffer.concat(stderr);
|
|
43
|
+
if (options.encoding !== 'binary') res.stderr = res.stderr.toString(options.encoding);
|
|
44
|
+
}
|
|
45
|
+
res.output = [
|
|
46
|
+
null,
|
|
47
|
+
res.stdout,
|
|
48
|
+
res.stderr
|
|
49
|
+
];
|
|
50
|
+
// patch: early node on windows could return null
|
|
51
|
+
if (res.status === null) res.status = 0;
|
|
52
|
+
// process errors
|
|
53
|
+
const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;
|
|
54
|
+
if (err) {
|
|
55
|
+
for(const key in res){
|
|
56
|
+
if (spawnKeys.indexOf(key) < 0) continue;
|
|
57
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
err ? callback(err) : callback(null, res);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
// pipe input
|
|
64
|
+
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
|
65
|
+
cp.stdin.end(options.input);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/async.ts"],"sourcesContent":["import once from 'call-once-fn';\nimport nextTick from 'next-tick';\nimport { spawnKeys } from '../constants';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types';\n\nexport default function worker(cp: ChildProcess, options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = once(callback);\n let stdout: Buffer[] = null;\n let stderr: Buffer[] = null;\n\n // collect output\n const res = { stdout: null, stderr: null } as SpawnResult;\n if (options.encoding) {\n if (cp.stdout) {\n stdout = [];\n cp.stdout.on('data', stdout.push.bind(stdout));\n }\n if (cp.stderr) {\n stderr = [];\n cp.stderr.on('data', stderr.push.bind(stderr));\n }\n }\n\n // some versions of node emit both an error and close\n cp.on('error', (err: SpawnError) => err.code === 'OK' || callback(err));\n\n // done\n cp.on('close', (status, signal) => {\n nextTick(function closeNextTick() {\n // prepare result\n res.pid = cp.pid;\n res.status = status;\n res.signal = signal;\n if (stdout) {\n res.stdout = Buffer.concat(stdout);\n if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);\n }\n if (stderr) {\n res.stderr = Buffer.concat(stderr);\n if (options.encoding !== 'binary') res.stderr = res.stderr.toString(options.encoding);\n }\n res.output = [null, res.stdout, res.stderr];\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n err ? callback(err) : callback(null, res);\n });\n });\n\n // pipe input\n if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {\n cp.stdin.end(options.input);\n }\n}\n"],"names":["once","nextTick","spawnKeys","worker","cp","options","callback","stdout","stderr","res","encoding","on","push","bind","err","code","status","signal","closeNextTick","pid","Buffer","concat","toString","output","Error","key","indexOf","isBuffer","input","stdin","end"],"mappings":"AAAA,OAAOA,UAAU,eAAe;AAChC,OAAOC,cAAc,YAAY;AACjC,SAASC,SAAS,QAAQ,eAAe;AAIzC,eAAe,SAASC,OAAOC,EAAgB,EAAEC,OAAsC,EAAEC,QAAwB;IAC/G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWN,KAAKM;IAChB,IAAIC,SAAmB;IACvB,IAAIC,SAAmB;IAEvB,iBAAiB;IACjB,MAAMC,MAAM;QAAEF,QAAQ;QAAMC,QAAQ;IAAK;IACzC,IAAIH,QAAQK,QAAQ,EAAE;QACpB,IAAIN,GAAGG,MAAM,EAAE;YACbA,SAAS,EAAE;YACXH,GAAGG,MAAM,CAACI,EAAE,CAAC,QAAQJ,OAAOK,IAAI,CAACC,IAAI,CAACN;QACxC;QACA,IAAIH,GAAGI,MAAM,EAAE;YACbA,SAAS,EAAE;YACXJ,GAAGI,MAAM,CAACG,EAAE,CAAC,QAAQH,OAAOI,IAAI,CAACC,IAAI,CAACL;QACxC;IACF;IAEA,qDAAqD;IACrDJ,GAAGO,EAAE,CAAC,SAAS,CAACG,MAAoBA,IAAIC,IAAI,KAAK,QAAQT,SAASQ;IAElE,OAAO;IACPV,GAAGO,EAAE,CAAC,SAAS,CAACK,QAAQC;QACtBhB,SAAS,SAASiB;YAChB,iBAAiB;YACjBT,IAAIU,GAAG,GAAGf,GAAGe,GAAG;YAChBV,IAAIO,MAAM,GAAGA;YACbP,IAAIQ,MAAM,GAAGA;YACb,IAAIV,QAAQ;gBACVE,IAAIF,MAAM,GAAGa,OAAOC,MAAM,CAACd;gBAC3B,IAAIF,QAAQK,QAAQ,KAAK,UAAUD,IAAIF,MAAM,GAAGE,IAAIF,MAAM,CAACe,QAAQ,CAACjB,QAAQK,QAAQ;YACtF;YACA,IAAIF,QAAQ;gBACVC,IAAID,MAAM,GAAGY,OAAOC,MAAM,CAACb;gBAC3B,IAAIH,QAAQK,QAAQ,KAAK,UAAUD,IAAID,MAAM,GAAGC,IAAID,MAAM,CAACc,QAAQ,CAACjB,QAAQK,QAAQ;YACtF;YACAD,IAAIc,MAAM,GAAG;gBAAC;gBAAMd,IAAIF,MAAM;gBAAEE,IAAID,MAAM;aAAC;YAE3C,iDAAiD;YACjD,IAAIC,IAAIO,MAAM,KAAK,MAAMP,IAAIO,MAAM,GAAG;YAEtC,iBAAiB;YACjB,MAAMF,MAAML,IAAIO,MAAM,KAAK,IAAI,IAAIQ,MAAM,CAAC,oBAAoB,EAAEf,IAAIO,MAAM,EAAE,IAAI;YAChF,IAAIF,KAAK;gBACP,IAAK,MAAMW,OAAOhB,IAAK;oBACrB,IAAIP,UAAUwB,OAAO,CAACD,OAAO,GAAG;oBAChCX,GAAG,CAACW,IAAI,GAAGL,OAAOO,QAAQ,CAAClB,GAAG,CAACgB,IAAI,IAAIhB,GAAG,CAACgB,IAAI,CAACH,QAAQ,CAAC,UAAUb,GAAG,CAACgB,IAAI;gBAC7E;YACF;YACAX,MAAMR,SAASQ,OAAOR,SAAS,MAAMG;QACvC;IACF;IAEA,aAAa;IACb,IAAIJ,QAAQuB,KAAK,IAAK,CAAA,OAAOvB,QAAQuB,KAAK,KAAK,YAAYR,OAAOO,QAAQ,CAACtB,QAAQuB,KAAK,CAAA,GAAI;QAC1FxB,GAAGyB,KAAK,CAACC,GAAG,CAACzB,QAAQuB,KAAK;IAC5B;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { spawnKeys } from '../constants.mjs';
|
|
2
|
+
export default function worker(res, options) {
|
|
3
|
+
options = options || {};
|
|
4
|
+
// pipe if inherited
|
|
5
|
+
if (res.stdout && options.stdio === 'inherit') {
|
|
6
|
+
process.stdout.write(res.stdout);
|
|
7
|
+
res.stdout = null;
|
|
8
|
+
}
|
|
9
|
+
if (res.stderr && options.stdio === 'inherit') {
|
|
10
|
+
process.stderr.write(res.stderr);
|
|
11
|
+
res.stderr = null;
|
|
12
|
+
}
|
|
13
|
+
// patch: early node on windows could return null
|
|
14
|
+
if (res.status === null) res.status = 0;
|
|
15
|
+
// process errors
|
|
16
|
+
const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;
|
|
17
|
+
if (err) {
|
|
18
|
+
for(const key in res){
|
|
19
|
+
if (spawnKeys.indexOf(key) < 0) continue;
|
|
20
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (err) throw err;
|
|
24
|
+
return res;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/sync.ts"],"sourcesContent":["import { spawnKeys } from '../constants';\n\nimport type { SpawnOptions, SpawnResult } from '../types';\n\nexport default function worker(res: SpawnResult, options?: SpawnOptions) {\n options = options || {};\n\n // pipe if inherited\n if (res.stdout && options.stdio === 'inherit') {\n process.stdout.write(res.stdout);\n res.stdout = null;\n }\n if (res.stderr && options.stdio === 'inherit') {\n process.stderr.write(res.stderr);\n res.stderr = null;\n }\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n if (err) throw err;\n return res;\n}\n"],"names":["spawnKeys","worker","res","options","stdout","stdio","process","write","stderr","status","err","Error","key","indexOf","Buffer","isBuffer","toString"],"mappings":"AAAA,SAASA,SAAS,QAAQ,eAAe;AAIzC,eAAe,SAASC,OAAOC,GAAgB,EAAEC,OAAsB;IACrEA,UAAUA,WAAW,CAAC;IAEtB,oBAAoB;IACpB,IAAID,IAAIE,MAAM,IAAID,QAAQE,KAAK,KAAK,WAAW;QAC7CC,QAAQF,MAAM,CAACG,KAAK,CAACL,IAAIE,MAAM;QAC/BF,IAAIE,MAAM,GAAG;IACf;IACA,IAAIF,IAAIM,MAAM,IAAIL,QAAQE,KAAK,KAAK,WAAW;QAC7CC,QAAQE,MAAM,CAACD,KAAK,CAACL,IAAIM,MAAM;QAC/BN,IAAIM,MAAM,GAAG;IACf;IAEA,iDAAiD;IACjD,IAAIN,IAAIO,MAAM,KAAK,MAAMP,IAAIO,MAAM,GAAG;IAEtC,iBAAiB;IACjB,MAAMC,MAAMR,IAAIO,MAAM,KAAK,IAAI,IAAIE,MAAM,CAAC,oBAAoB,EAAET,IAAIO,MAAM,EAAE,IAAI;IAChF,IAAIC,KAAK;QACP,IAAK,MAAME,OAAOV,IAAK;YACrB,IAAIF,UAAUa,OAAO,CAACD,OAAO,GAAG;YAChCF,GAAG,CAACE,IAAI,GAAGE,OAAOC,QAAQ,CAACb,GAAG,CAACU,IAAI,IAAIV,GAAG,CAACU,IAAI,CAACI,QAAQ,CAAC,UAAUd,GAAG,CAACU,IAAI;QAC7E;IACF;IACA,IAAIF,KAAK,MAAMA;IACf,OAAOR;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const spawnKeys: string[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import asyncWorker from './workers/async';
|
|
2
|
+
import syncWorker from './workers/sync';
|
|
3
|
+
export type * from './types';
|
|
4
|
+
export declare function sync(command: string, args: string[], options?: SpawnOptions): SpawnResult;
|
|
5
|
+
export declare namespace sync {
|
|
6
|
+
var worker: typeof syncWorker;
|
|
7
|
+
}
|
|
8
|
+
import type { SpawnCallback, SpawnOptions, SpawnResult } from './types';
|
|
9
|
+
declare function spawnCallback(command: string, args: string[], options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): undefined | Promise<SpawnResult>;
|
|
10
|
+
declare namespace spawnCallback {
|
|
11
|
+
var worker: typeof asyncWorker;
|
|
12
|
+
var sync: typeof import(".").sync;
|
|
13
|
+
var crossSpawn: any;
|
|
14
|
+
}
|
|
15
|
+
export default spawnCallback;
|
|
16
|
+
export declare const crossSpawn: any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SpawnOptions as SpawnOptionsBase, SpawnSyncReturns } from 'child_process';
|
|
2
|
+
export type { ChildProcess } from 'child_process';
|
|
3
|
+
export interface SpawnOptions extends SpawnOptionsBase {
|
|
4
|
+
encoding?: BufferEncoding;
|
|
5
|
+
env?: NodeJS.ProcessEnv;
|
|
6
|
+
input?: string | Buffer;
|
|
7
|
+
}
|
|
8
|
+
export type SpawnResult = SpawnSyncReturns<string | Buffer>;
|
|
9
|
+
export interface SpawnError extends Error {
|
|
10
|
+
status?: number;
|
|
11
|
+
stderr?: string | Buffer;
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
export type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cross-spawn-cb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Cross spawn with a completion callback",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cross-spawn",
|
|
@@ -12,7 +12,17 @@
|
|
|
12
12
|
"url": "git@github.com:kmalakoff/cross-spawn-cb.git"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/esm/index.mjs",
|
|
19
|
+
"require": "./dist/cjs/index.cjs",
|
|
20
|
+
"types": "./dist/types/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./*": "./*"
|
|
23
|
+
},
|
|
24
|
+
"main": "dist/cjs/index.cjs",
|
|
25
|
+
"module": "dist/esm/index.mjs",
|
|
16
26
|
"types": "dist/types/index.d.ts",
|
|
17
27
|
"files": [
|
|
18
28
|
"dist",
|
|
@@ -39,19 +49,16 @@
|
|
|
39
49
|
"@types/mocha": "^10.0.10",
|
|
40
50
|
"@types/node": "^22.10.2",
|
|
41
51
|
"cr": "^0.1.0",
|
|
42
|
-
"depcheck": "^1.4.7",
|
|
43
52
|
"is-version": "^0.2.1",
|
|
44
53
|
"node-install-release": "^1.6.3",
|
|
45
54
|
"node-resolve-versions": "^1.0.5",
|
|
46
|
-
"node-version-utils": "^1.
|
|
55
|
+
"node-version-utils": "^1.2.0",
|
|
56
|
+
"pinkie-promise": "^2.0.1"
|
|
47
57
|
},
|
|
48
58
|
"engines": {
|
|
49
59
|
"node": ">=0.8"
|
|
50
60
|
},
|
|
51
61
|
"tsds": {
|
|
52
|
-
"source": "src/index.
|
|
53
|
-
"targets": [
|
|
54
|
-
"cjs"
|
|
55
|
-
]
|
|
62
|
+
"source": "src/index.ts"
|
|
56
63
|
}
|
|
57
64
|
}
|
package/assets/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/constants.js"],"sourcesContent":["module.exports = {\n spawnKeys: ['pid', 'status', 'signal', 'stdout', 'stderr', 'output'],\n};\n"],"names":["module","exports","spawnKeys"],"mappings":";AAAAA,OAAOC,OAAO,GAAG;IACfC,WAAW;QAAC;QAAO;QAAU;QAAU;QAAU;QAAU;KAAS;AACtE"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var spawn_ = require('./spawn.js');
|
|
3
|
-
module.exports = require('./workers/spawnCallback.js');
|
|
4
|
-
module.exports.sync = require('./workers/spawnSyncCallback.js');
|
|
5
|
-
module.exports.spawn = spawn_;
|
|
6
|
-
module.exports._parse = spawn_._parse;
|
|
7
|
-
module.exports._enoent = spawn_._enoent;
|
|
8
|
-
/* 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/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/index.cjs"],"sourcesContent":["const spawn_ = require('./spawn.cjs');\nmodule.exports = require('./workers/spawnCallback.cjs');\nmodule.exports.sync = require('./workers/spawnSyncCallback.cjs');\nmodule.exports.spawn = spawn_;\nmodule.exports._parse = spawn_._parse;\nmodule.exports._enoent = spawn_._enoent;\n"],"names":["spawn_","require","module","exports","sync","spawn","_parse","_enoent"],"mappings":";AAAA,IAAMA,SAASC,QAAQ;AACvBC,OAAOC,OAAO,GAAGF,QAAQ;AACzBC,OAAOC,OAAO,CAACC,IAAI,GAAGH,QAAQ;AAC9BC,OAAOC,OAAO,CAACE,KAAK,GAAGL;AACvBE,OAAOC,OAAO,CAACG,MAAM,GAAGN,OAAOM,MAAM;AACrCJ,OAAOC,OAAO,CAACI,OAAO,GAAGP,OAAOO,OAAO"}
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawCompat.cjs"],"sourcesContent":["require('./polyfills.cjs');\nconst path = require('path');\nconst cp = require('child_process');\nconst spawn_ = require('../../assets/cross-spawn.js');\n\nconst NODES = ['node', 'node.exe', 'node.cmd'];\nfunction parse(command, args, options) {\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;\n }\n return spawn_._parse(command, args, options);\n}\nconst enoent = spawn_._enoent;\n\nfunction spawn(command, args, options) {\n const parsed = parse(command, args, options);\n const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);\n enoent.hookChildProcess(spawned, parsed);\n return spawned;\n}\n\nfunction spawnSync(command, args, options) {\n const parsed = parse(command, args, options);\n const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);\n result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);\n return result;\n}\n\nmodule.exports = spawn;\nmodule.exports.spawn = spawn;\nmodule.exports.sync = spawnSync;\nmodule.exports._parse = parse;\nmodule.exports._enoent = enoent;\n"],"names":["require","path","cp","spawn_","NODES","parse","command","args","options","indexOf","basename","toLowerCase","env","process","NODE","npm_node_execpath","_parse","enoent","_enoent","spawn","parsed","spawned","hookChildProcess","spawnSync","result","error","verifyENOENTSync","status","module","exports","sync"],"mappings":";AAAAA,QAAQ;AACR,IAAMC,OAAOD,QAAQ;AACrB,IAAME,KAAKF,QAAQ;AACnB,IAAMG,SAASH,QAAQ;AAEvB,IAAMI,QAAQ;IAAC;IAAQ;IAAY;CAAW;AAC9C,SAASC,MAAMC,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAIJ,MAAMK,OAAO,CAACR,KAAKS,QAAQ,CAACJ,SAASK,WAAW,OAAO,GAAG;QAC5D,IAAMC,MAAMJ,UAAUA,QAAQI,GAAG,IAAIC,QAAQD,GAAG,GAAGC,QAAQD,GAAG;QAC9DN,UAAUM,IAAIE,IAAI,IAAIF,IAAIG,iBAAiB;IAC7C;IACA,OAAOZ,OAAOa,MAAM,CAACV,SAASC,MAAMC;AACtC;AACA,IAAMS,SAASd,OAAOe,OAAO;AAE7B,SAASC,MAAMb,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,IAAMa,UAAUnB,GAAGiB,KAAK,CAACC,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACpES,OAAOK,gBAAgB,CAACD,SAASD;IACjC,OAAOC;AACT;AAEA,SAASE,UAAUjB,OAAO,EAAEC,IAAI,EAAEC,OAAO;IACvC,IAAMY,SAASf,MAAMC,SAASC,MAAMC;IACpC,IAAMgB,SAAStB,GAAGqB,SAAS,CAACH,OAAOd,OAAO,EAAEc,OAAOb,IAAI,EAAEa,OAAOZ,OAAO;IACvEgB,OAAOC,KAAK,GAAGD,OAAOC,KAAK,IAAIR,OAAOS,gBAAgB,CAACF,OAAOG,MAAM,EAAEP;IACtE,OAAOI;AACT;AAEAI,OAAOC,OAAO,GAAGV;AACjBS,OAAOC,OAAO,CAACV,KAAK,GAAGA;AACvBS,OAAOC,OAAO,CAACC,IAAI,GAAGP;AACtBK,OAAOC,OAAO,CAACb,MAAM,GAAGX;AACxBuB,OAAOC,OAAO,CAACX,OAAO,GAAGD"}
|
package/dist/cjs/spawn.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawn.cjs"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\n\nmodule.exports = major <= 7 ? require('./spawCompat.cjs') : require('cross-spawn');\n"],"names":["major","process","versions","node","split","module","exports","require"],"mappings":";AAAA,IAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElDC,OAAOC,OAAO,GAAGN,SAAS,IAAIO,QAAQ,sBAAsBA,QAAQ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/spawnCallback.cjs"],"sourcesContent":["const once = require('call-once-fn');\nconst nextTick = require('next-tick');\nconst constants = require('../constants.js');\nconst spawn = require('../spawn.js');\n\nfunction worker(cp, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = once(callback);\n\n // collect output\n const res = { stdout: null, stderr: null };\n if (options.encoding) {\n if (cp.stdout) {\n res.stdout = [];\n cp.stdout.on('data', res.stdout.push.bind(res.stdout));\n }\n if (cp.stderr) {\n res.stderr = [];\n cp.stderr.on('data', res.stderr.push.bind(res.stderr));\n }\n }\n\n // some versions of node emit both an error and close\n cp.on('error', function error(err) {\n err.code === 'OK' || callback(err);\n });\n\n // done\n cp.on('close', (status, signal) => {\n nextTick(function closeNextTick() {\n // prepare result\n res.pid = cp.pid;\n res.status = status;\n res.signal = signal;\n if (res.stdout) {\n res.stdout = Buffer.concat(res.stdout);\n if (options.encoding !== 'buffer') res.stdout = res.stdout.toString(options.encoding);\n }\n if (res.stderr) {\n res.stderr = Buffer.concat(res.stderr);\n if (options.encoding !== 'buffer') res.stderr = res.stderr.toString(options.encoding);\n }\n res.output = [null, res.stdout, res.stderr];\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (constants.spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n err ? callback(err) : callback(null, res);\n });\n });\n\n // pipe input\n if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {\n cp.stdin.end(options.input);\n }\n}\n\nfunction spawnCallback(command, args, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = once(callback);\n const cp = spawn(command, args, options);\n return worker(cp, options, callback);\n}\n\nmodule.exports = spawnCallback;\nmodule.exports.worker = worker;\n"],"names":["once","require","nextTick","constants","spawn","worker","cp","options","callback","res","stdout","stderr","encoding","on","push","bind","error","err","code","status","signal","closeNextTick","pid","Buffer","concat","toString","output","Error","key","spawnKeys","indexOf","isBuffer","input","stdin","end","spawnCallback","command","args","module","exports"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,WAAWD,QAAQ;AACzB,IAAME,YAAYF,QAAQ;AAC1B,IAAMG,QAAQH,QAAQ;AAEtB,SAASI,OAAOC,EAAE,EAAEC,OAAO,EAAEC,QAAQ;IACnC,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWR,KAAKQ;IAEhB,iBAAiB;IACjB,IAAMC,MAAM;QAAEC,QAAQ;QAAMC,QAAQ;IAAK;IACzC,IAAIJ,QAAQK,QAAQ,EAAE;QACpB,IAAIN,GAAGI,MAAM,EAAE;YACbD,IAAIC,MAAM,GAAG,EAAE;YACfJ,GAAGI,MAAM,CAACG,EAAE,CAAC,QAAQJ,IAAIC,MAAM,CAACI,IAAI,CAACC,IAAI,CAACN,IAAIC,MAAM;QACtD;QACA,IAAIJ,GAAGK,MAAM,EAAE;YACbF,IAAIE,MAAM,GAAG,EAAE;YACfL,GAAGK,MAAM,CAACE,EAAE,CAAC,QAAQJ,IAAIE,MAAM,CAACG,IAAI,CAACC,IAAI,CAACN,IAAIE,MAAM;QACtD;IACF;IAEA,qDAAqD;IACrDL,GAAGO,EAAE,CAAC,SAAS,SAASG,MAAMC,GAAG;QAC/BA,IAAIC,IAAI,KAAK,QAAQV,SAASS;IAChC;IAEA,OAAO;IACPX,GAAGO,EAAE,CAAC,SAAS,SAACM,QAAQC;QACtBlB,SAAS,SAASmB;YAChB,iBAAiB;YACjBZ,IAAIa,GAAG,GAAGhB,GAAGgB,GAAG;YAChBb,IAAIU,MAAM,GAAGA;YACbV,IAAIW,MAAM,GAAGA;YACb,IAAIX,IAAIC,MAAM,EAAE;gBACdD,IAAIC,MAAM,GAAGa,OAAOC,MAAM,CAACf,IAAIC,MAAM;gBACrC,IAAIH,QAAQK,QAAQ,KAAK,UAAUH,IAAIC,MAAM,GAAGD,IAAIC,MAAM,CAACe,QAAQ,CAAClB,QAAQK,QAAQ;YACtF;YACA,IAAIH,IAAIE,MAAM,EAAE;gBACdF,IAAIE,MAAM,GAAGY,OAAOC,MAAM,CAACf,IAAIE,MAAM;gBACrC,IAAIJ,QAAQK,QAAQ,KAAK,UAAUH,IAAIE,MAAM,GAAGF,IAAIE,MAAM,CAACc,QAAQ,CAAClB,QAAQK,QAAQ;YACtF;YACAH,IAAIiB,MAAM,GAAG;gBAAC;gBAAMjB,IAAIC,MAAM;gBAAED,IAAIE,MAAM;aAAC;YAE3C,iDAAiD;YACjD,IAAIF,IAAIU,MAAM,KAAK,MAAMV,IAAIU,MAAM,GAAG;YAEtC,iBAAiB;YACjB,IAAMF,MAAMR,IAAIU,MAAM,KAAK,IAAI,IAAIQ,MAAM,AAAC,uBAAiC,OAAXlB,IAAIU,MAAM,KAAM;YAChF,IAAIF,KAAK;gBACP,IAAK,IAAMW,OAAOnB,IAAK;oBACrB,IAAIN,UAAU0B,SAAS,CAACC,OAAO,CAACF,OAAO,GAAG;oBAC1CX,GAAG,CAACW,IAAI,GAAGL,OAAOQ,QAAQ,CAACtB,GAAG,CAACmB,IAAI,IAAInB,GAAG,CAACmB,IAAI,CAACH,QAAQ,CAAC,UAAUhB,GAAG,CAACmB,IAAI;gBAC7E;YACF;YACAX,MAAMT,SAASS,OAAOT,SAAS,MAAMC;QACvC;IACF;IAEA,aAAa;IACb,IAAIF,QAAQyB,KAAK,IAAK,CAAA,OAAOzB,QAAQyB,KAAK,KAAK,YAAYT,OAAOQ,QAAQ,CAACxB,QAAQyB,KAAK,CAAA,GAAI;QAC1F1B,GAAG2B,KAAK,CAACC,GAAG,CAAC3B,QAAQyB,KAAK;IAC5B;AACF;AAEA,SAASG,cAAcC,OAAO,EAAEC,IAAI,EAAE9B,OAAO,EAAEC,QAAQ;IACrD,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWR,KAAKQ;IAChB,IAAMF,KAAKF,MAAMgC,SAASC,MAAM9B;IAChC,OAAOF,OAAOC,IAAIC,SAASC;AAC7B;AAEA8B,OAAOC,OAAO,GAAGJ;AACjBG,OAAOC,OAAO,CAAClC,MAAM,GAAGA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/spawnSyncCallback.cjs"],"sourcesContent":["const constants = require('../constants.js');\nconst spawn = require('../spawn.js');\n\nfunction worker(res, options) {\n // pipe if inherited\n if (res.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {\n process.stdout.write(res.stdout);\n res.stdout = null;\n }\n if (res.stderr && (options.stderr === 'inherit' || options.stdio === 'inherit')) {\n process.stderr.write(res.stderr);\n res.stderr = null;\n }\n\n // patch: early node on windows could return null\n if (res.status === null) res.status = 0;\n\n // process errors\n const err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (err) {\n for (const key in res) {\n if (constants.spawnKeys.indexOf(key) < 0) continue;\n err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];\n }\n }\n if (err) throw err;\n return res;\n}\n\nfunction spawnCallbackSync(command, args, options) {\n options = options || {};\n const syncOptions = { ...options, env: options.env || process.env, stdio: 'pipe', encoding: 'utf8' };\n const res = spawn.sync(command, args, syncOptions);\n return worker(res, options);\n}\n\nmodule.exports = spawnCallbackSync;\nmodule.exports.worker = worker;\n"],"names":["constants","require","spawn","worker","res","options","stdout","stdio","process","write","stderr","status","err","Error","key","spawnKeys","indexOf","Buffer","isBuffer","toString","spawnCallbackSync","command","args","syncOptions","env","encoding","sync","module","exports"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,YAAYC,QAAQ;AAC1B,IAAMC,QAAQD,QAAQ;AAEtB,SAASE,OAAOC,GAAG,EAAEC,OAAO;IAC1B,oBAAoB;IACpB,IAAID,IAAIE,MAAM,IAAKD,CAAAA,QAAQC,MAAM,KAAK,aAAaD,QAAQE,KAAK,KAAK,SAAQ,GAAI;QAC/EC,QAAQF,MAAM,CAACG,KAAK,CAACL,IAAIE,MAAM;QAC/BF,IAAIE,MAAM,GAAG;IACf;IACA,IAAIF,IAAIM,MAAM,IAAKL,CAAAA,QAAQK,MAAM,KAAK,aAAaL,QAAQE,KAAK,KAAK,SAAQ,GAAI;QAC/EC,QAAQE,MAAM,CAACD,KAAK,CAACL,IAAIM,MAAM;QAC/BN,IAAIM,MAAM,GAAG;IACf;IAEA,iDAAiD;IACjD,IAAIN,IAAIO,MAAM,KAAK,MAAMP,IAAIO,MAAM,GAAG;IAEtC,iBAAiB;IACjB,IAAMC,MAAMR,IAAIO,MAAM,KAAK,IAAI,IAAIE,MAAM,AAAC,uBAAiC,OAAXT,IAAIO,MAAM,KAAM;IAChF,IAAIC,KAAK;QACP,IAAK,IAAME,OAAOV,IAAK;YACrB,IAAIJ,UAAUe,SAAS,CAACC,OAAO,CAACF,OAAO,GAAG;YAC1CF,GAAG,CAACE,IAAI,GAAGG,OAAOC,QAAQ,CAACd,GAAG,CAACU,IAAI,IAAIV,GAAG,CAACU,IAAI,CAACK,QAAQ,CAAC,UAAUf,GAAG,CAACU,IAAI;QAC7E;IACF;IACA,IAAIF,KAAK,MAAMA;IACf,OAAOR;AACT;AAEA,SAASgB,kBAAkBC,OAAO,EAAEC,IAAI,EAAEjB,OAAO;IAC/CA,UAAUA,WAAW,CAAC;IACtB,IAAMkB,cAAc,wCAAKlB;QAASmB,KAAKnB,QAAQmB,GAAG,IAAIhB,QAAQgB,GAAG;QAAEjB,OAAO;QAAQkB,UAAU;;IAC5F,IAAMrB,MAAMF,MAAMwB,IAAI,CAACL,SAASC,MAAMC;IACtC,OAAOpB,OAAOC,KAAKC;AACrB;AAEAsB,OAAOC,OAAO,GAAGR;AACjBO,OAAOC,OAAO,CAACzB,MAAM,GAAGA"}
|
package/dist/types/index.d.cts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const _exports: {
|
|
2
|
-
(command: any, args: any, options: any, callback: any): void;
|
|
3
|
-
worker: typeof import("./workers/spawnCallback.cjs").worker;
|
|
4
|
-
sync: typeof import("./workers/spawnSyncCallback.cjs");
|
|
5
|
-
spawn: any;
|
|
6
|
-
_parse: any;
|
|
7
|
-
_enoent: any;
|
|
8
|
-
};
|
|
9
|
-
export = _exports;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|