cross-spawn-cb 0.6.18 → 1.1.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/README.md +1 -1
- package/dist/cjs/constants.js +7 -12
- package/dist/cjs/index.js +31 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/polyfills.js +10 -15
- package/dist/cjs/polyfills.js.map +1 -1
- package/dist/cjs/spawn.js +5 -0
- package/dist/cjs/spawn.js.map +1 -0
- package/dist/cjs/spawnCallback.js +32 -29
- package/dist/cjs/spawnCallback.js.map +1 -1
- package/dist/cjs/spawnCallbackSync.js +39 -0
- package/dist/cjs/spawnCallbackSync.js.map +1 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/spawn.d.ts +2 -0
- package/dist/types/spawnCallback.d.ts +6 -2
- package/dist/types/spawnCallbackSync.d.ts +6 -0
- package/package.json +14 -13
- package/dist/cjs/spawnSyncCallback.js +0 -42
- package/dist/cjs/spawnSyncCallback.js.map +0 -1
- package/dist/types/index.d.ts +0 -6
- package/dist/types/spawnSyncCallback.d.ts +0 -2
- /package/dist/types/{polyfills.d.ts → polyfills.d.cts} +0 -0
package/README.md
CHANGED
package/dist/cjs/constants.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
module.exports = {
|
|
3
3
|
spawnKeys: [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
'pid',
|
|
5
|
+
'status',
|
|
6
|
+
'signal',
|
|
7
|
+
'stdout',
|
|
8
|
+
'stderr',
|
|
9
|
+
'output'
|
|
10
10
|
]
|
|
11
11
|
};
|
|
12
|
-
|
|
13
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
14
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
15
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
16
|
-
module.exports = exports.default;
|
|
17
|
-
}
|
|
12
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
default: function() {
|
|
13
|
+
return _default;
|
|
14
|
+
},
|
|
15
|
+
spawn: function() {
|
|
16
|
+
return _spawn.default;
|
|
17
|
+
},
|
|
18
|
+
sync: function() {
|
|
19
|
+
return _spawnCallbackSync.default;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
require("./polyfills.js");
|
|
23
|
+
var _spawnCallback = /*#__PURE__*/ _interop_require_default(require("./spawnCallback"));
|
|
24
|
+
var _spawn = /*#__PURE__*/ _interop_require_default(require("./spawn"));
|
|
25
|
+
var _spawnCallbackSync = /*#__PURE__*/ _interop_require_default(require("./spawnCallbackSync"));
|
|
26
|
+
function _interop_require_default(obj) {
|
|
27
|
+
return obj && obj.__esModule ? obj : {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
var _default = _spawnCallback.default;
|
|
32
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.
|
|
1
|
+
{"version":3,"sources":["index.mjs"],"sourcesContent":["import './polyfills.cjs';\n\nimport spawnCallback from './spawnCallback';\n\nexport default spawnCallback;\nexport { default as spawn } from './spawn';\nexport { default as sync } from './spawnCallbackSync';\n"],"names":["spawn","sync","spawnCallback"],"mappings":";;;;;;;;;;;IAIA,OAA6B;eAA7B;;IACoBA,KAAK;eAALA,cAAK;;IACLC,IAAI;eAAJA,0BAAI;;;QANjB;oEAEmB;4DAGO;wEACD;;;;;;IAFhC,WAAeC,sBAAa"}
|
package/dist/cjs/polyfills.js
CHANGED
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require(
|
|
3
|
-
require(
|
|
4
|
-
require(
|
|
5
|
-
require(
|
|
6
|
-
var path = require(
|
|
7
|
-
if (!path.delimiter) path.delimiter = process.platform ===
|
|
8
|
-
var cp = require(
|
|
2
|
+
require('core-js/actual/object/assign');
|
|
3
|
+
require('core-js/actual/object/keys');
|
|
4
|
+
require('core-js/actual/array/find');
|
|
5
|
+
require('buffer-v6-polyfill');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
if (!path.delimiter) path.delimiter = process.platform === 'win32' ? ';' : ':';
|
|
8
|
+
var cp = require('child_process');
|
|
9
9
|
if (!cp.spawnSync) {
|
|
10
|
-
var spawnCallback = path.join(__dirname,
|
|
10
|
+
var spawnCallback = path.join(__dirname, 'spawnCallback.js');
|
|
11
11
|
var functionExec = null; // break dependencies
|
|
12
12
|
cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {
|
|
13
|
-
if (!functionExec) functionExec = require(
|
|
13
|
+
if (!functionExec) functionExec = require('function-exec-sync');
|
|
14
14
|
return functionExec({
|
|
15
15
|
callbacks: true
|
|
16
16
|
}, spawnCallback, cmd, args, options || {});
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
21
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
22
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
23
|
-
module.exports = exports.default;
|
|
24
|
-
}
|
|
19
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["polyfills.
|
|
1
|
+
{"version":3,"sources":["polyfills.cjs"],"sourcesContent":["require('core-js/actual/object/assign');\nrequire('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, '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;AACRA,QAAQ;AAER,IAAMC,OAAOD,QAAQ;AACrB,IAAI,CAACC,KAAKC,SAAS,EAAED,KAAKC,SAAS,GAAGC,QAAQC,QAAQ,KAAK,UAAU,MAAM;AAE3E,IAAMC,KAAKL,QAAQ;AACnB,IAAI,CAACK,GAAGC,SAAS,EAAE;IACjB,IAAMC,gBAAgBN,KAAKO,IAAI,CAACC,WAAW;IAE3C,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,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var major = +process.versions.node.split('.')[0];
|
|
3
|
+
var spawn = major <= 7 ? require('../../assets/cross-spawn-6.0.5.js').spawn : require('cross-spawn').spawn;
|
|
4
|
+
module.exports = spawn;
|
|
5
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["spawn.js"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\nconst spawn = major <= 7 ? require('../../assets/cross-spawn-6.0.5.js').spawn : require('cross-spawn').spawn;\n\nmodule.exports = spawn;\n"],"names":["major","process","versions","node","split","spawn","require","module","exports"],"mappings":";AAAA,IAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,QAAQL,SAAS,IAAIM,QAAQ,qCAAqCD,KAAK,GAAGC,QAAQ,eAAeD,KAAK;AAE5GE,OAAOC,OAAO,GAAGH"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require(
|
|
3
|
-
var once = require(
|
|
4
|
-
var nextTick = require(
|
|
5
|
-
var constants = require(
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (typeof options === "function") {
|
|
2
|
+
require('./polyfills.js');
|
|
3
|
+
var once = require('once');
|
|
4
|
+
var nextTick = require('next-tick');
|
|
5
|
+
var constants = require('./constants');
|
|
6
|
+
var spawn = require('./spawn');
|
|
7
|
+
function normalize(cp, options, callback) {
|
|
8
|
+
if (typeof options === 'function') {
|
|
10
9
|
callback = options;
|
|
11
10
|
options = {};
|
|
12
11
|
}
|
|
13
12
|
options = options || {};
|
|
14
13
|
callback = once(callback);
|
|
15
|
-
var cp = spawn(command, args, options);
|
|
16
14
|
// collect output
|
|
17
15
|
var res = {
|
|
18
16
|
stdout: null,
|
|
@@ -21,19 +19,19 @@ module.exports = function spawnCallback(command, args, options, callback) {
|
|
|
21
19
|
if (options.encoding) {
|
|
22
20
|
if (cp.stdout) {
|
|
23
21
|
res.stdout = [];
|
|
24
|
-
cp.stdout.on(
|
|
22
|
+
cp.stdout.on('data', res.stdout.push.bind(res.stdout));
|
|
25
23
|
}
|
|
26
24
|
if (cp.stderr) {
|
|
27
25
|
res.stderr = [];
|
|
28
|
-
cp.stderr.on(
|
|
26
|
+
cp.stderr.on('data', res.stderr.push.bind(res.stderr));
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
29
|
// some versions of node emit both an error and close
|
|
32
|
-
cp.on(
|
|
33
|
-
err.code ===
|
|
30
|
+
cp.on('error', function error(err) {
|
|
31
|
+
err.code === 'OK' || callback(err);
|
|
34
32
|
});
|
|
35
33
|
// done
|
|
36
|
-
cp.on(
|
|
34
|
+
cp.on('close', function(status, signal) {
|
|
37
35
|
nextTick(function closeNextTick() {
|
|
38
36
|
// prepare result
|
|
39
37
|
res.pid = cp.pid;
|
|
@@ -41,11 +39,11 @@ module.exports = function spawnCallback(command, args, options, callback) {
|
|
|
41
39
|
res.signal = signal;
|
|
42
40
|
if (res.stdout) {
|
|
43
41
|
res.stdout = Buffer.concat(res.stdout);
|
|
44
|
-
if (options.encoding !==
|
|
42
|
+
if (options.encoding !== 'buffer') res.stdout = res.stdout.toString(options.encoding);
|
|
45
43
|
}
|
|
46
44
|
if (res.stderr) {
|
|
47
45
|
res.stderr = Buffer.concat(res.stderr);
|
|
48
|
-
if (options.encoding !==
|
|
46
|
+
if (options.encoding !== 'buffer') res.stderr = res.stderr.toString(options.encoding);
|
|
49
47
|
}
|
|
50
48
|
res.output = [
|
|
51
49
|
null,
|
|
@@ -53,28 +51,33 @@ module.exports = function spawnCallback(command, args, options, callback) {
|
|
|
53
51
|
res.stderr
|
|
54
52
|
];
|
|
55
53
|
// patch: early node on windows could return null
|
|
56
|
-
if (res.status === null)
|
|
57
|
-
// res.status = res.status === null ? 0 : res.status;
|
|
54
|
+
if (res.status === null) res.status = 0;
|
|
58
55
|
// process errors
|
|
59
56
|
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
60
|
-
if (
|
|
61
|
-
err = err || new Error("stderr has content");
|
|
57
|
+
if (err) {
|
|
62
58
|
for(var key in res){
|
|
63
59
|
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
64
|
-
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString(
|
|
60
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
65
61
|
}
|
|
66
62
|
}
|
|
67
63
|
err ? callback(err) : callback(null, res);
|
|
68
64
|
});
|
|
69
65
|
});
|
|
70
66
|
// pipe input
|
|
71
|
-
if (options.input && (typeof options.input ===
|
|
67
|
+
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
|
72
68
|
cp.stdin.end(options.input);
|
|
73
69
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
70
|
+
}
|
|
71
|
+
function spawnCallback(command, args, options, callback) {
|
|
72
|
+
if (typeof options === 'function') {
|
|
73
|
+
callback = options;
|
|
74
|
+
options = {};
|
|
75
|
+
}
|
|
76
|
+
options = options || {};
|
|
77
|
+
callback = once(callback);
|
|
78
|
+
var cp = spawn(command, args, options);
|
|
79
|
+
return normalize(cp, options, callback);
|
|
80
|
+
}
|
|
81
|
+
module.exports = spawnCallback;
|
|
82
|
+
module.exports.normalize = normalize;
|
|
83
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["spawnCallback.js"],"sourcesContent":["require('./polyfills');\nconst once = require('once');\nconst nextTick = require('next-tick');\nconst constants = require('./constants');\
|
|
1
|
+
{"version":3,"sources":["spawnCallback.js"],"sourcesContent":["require('./polyfills.cjs');\nconst once = require('once');\nconst nextTick = require('next-tick');\nconst constants = require('./constants');\nconst spawn = require('./spawn');\n\nfunction normalize(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 normalize(cp, options, callback);\n}\n\nmodule.exports = spawnCallback;\nmodule.exports.normalize = normalize;\n"],"names":["require","once","nextTick","constants","spawn","normalize","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":"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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var constants = require('./constants');
|
|
3
|
+
var spawn = require('./spawn');
|
|
4
|
+
function normalize(res, options) {
|
|
5
|
+
// pipe if inherited
|
|
6
|
+
if (res.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {
|
|
7
|
+
process.stdout.write(res.stdout);
|
|
8
|
+
res.stdout = null;
|
|
9
|
+
}
|
|
10
|
+
if (res.stderr && (options.stderr === 'inherit' || options.stdio === 'inherit')) {
|
|
11
|
+
process.stderr.write(res.stderr);
|
|
12
|
+
res.stderr = null;
|
|
13
|
+
}
|
|
14
|
+
// patch: early node on windows could return null
|
|
15
|
+
if (res.status === null) res.status = 0;
|
|
16
|
+
// process errors
|
|
17
|
+
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
18
|
+
if (err) {
|
|
19
|
+
for(var key in res){
|
|
20
|
+
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
21
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (err) throw err;
|
|
25
|
+
return res;
|
|
26
|
+
}
|
|
27
|
+
function spawnCallbackSync(command, args, options) {
|
|
28
|
+
options = options || {};
|
|
29
|
+
var syncOptions = Object.assign({}, options || {}, {
|
|
30
|
+
env: options.env || process.env,
|
|
31
|
+
stdio: 'pipe',
|
|
32
|
+
encoding: 'utf8'
|
|
33
|
+
});
|
|
34
|
+
var res = spawn.sync(command, args, syncOptions);
|
|
35
|
+
return normalize(res, options);
|
|
36
|
+
}
|
|
37
|
+
module.exports = spawnCallbackSync;
|
|
38
|
+
module.exports.normalize = normalize;
|
|
39
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["spawnCallbackSync.js"],"sourcesContent":["const constants = require('./constants');\nconst spawn = require('./spawn');\n\nfunction normalize(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\n const syncOptions = Object.assign({}, options || {}, {\n env: options.env || process.env,\n stdio: 'pipe',\n encoding: 'utf8',\n });\n const res = spawn.sync(command, args, syncOptions);\n\n return normalize(res, options);\n}\n\nmodule.exports = spawnCallbackSync;\nmodule.exports.normalize = normalize;\n"],"names":["constants","require","spawn","normalize","res","options","stdout","stdio","process","write","stderr","status","err","Error","key","spawnKeys","indexOf","Buffer","isBuffer","toString","spawnCallbackSync","command","args","syncOptions","Object","assign","env","encoding","sync","module","exports"],"mappings":";AAAA,IAAMA,YAAYC,QAAQ;AAC1B,IAAMC,QAAQD,QAAQ;AAEtB,SAASE,UAAUC,GAAG,EAAEC,OAAO;IAC7B,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;IAEtB,IAAMkB,cAAcC,OAAOC,MAAM,CAAC,CAAC,GAAGpB,WAAW,CAAC,GAAG;QACnDqB,KAAKrB,QAAQqB,GAAG,IAAIlB,QAAQkB,GAAG;QAC/BnB,OAAO;QACPoB,UAAU;IACZ;IACA,IAAMvB,MAAMF,MAAM0B,IAAI,CAACP,SAASC,MAAMC;IAEtC,OAAOpB,UAAUC,KAAKC;AACxB;AAEAwB,OAAOC,OAAO,GAAGV;AACjBS,OAAOC,OAAO,CAAC3B,SAAS,GAAGA"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export = spawnCallback;
|
|
2
|
+
declare function spawnCallback(command: any, args: any, options: any, callback: any): void;
|
|
3
|
+
declare namespace spawnCallback {
|
|
4
|
+
export { normalize };
|
|
5
|
+
}
|
|
6
|
+
declare function normalize(cp: any, options: any, callback: any): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cross-spawn-cb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Cross spawn with a completion callback",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cross-spawn",
|
|
@@ -21,37 +21,38 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsds build",
|
|
23
23
|
"deploy": "tsds deploy",
|
|
24
|
-
"format": "biome check --
|
|
25
|
-
"test": "mocha-compat test/**/*.test.js --no-timeouts",
|
|
24
|
+
"format": "biome check --write --unsafe src/ test/",
|
|
25
|
+
"test": "ts-swc node_modules/.bin/mocha-compat test/**/*.test.js --no-timeouts",
|
|
26
26
|
"test:engines": "nvu engines npm test",
|
|
27
27
|
"version": "tsds version"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"buffer-v6-polyfill": "^1.0.5",
|
|
31
|
-
"core-js": "^3.
|
|
32
|
-
"cross-spawn": "^7.0.
|
|
33
|
-
"function-exec-sync": "^0.
|
|
31
|
+
"core-js": "^3.39.0",
|
|
32
|
+
"cross-spawn": "^7.0.6",
|
|
33
|
+
"function-exec-sync": "^1.0.0",
|
|
34
34
|
"next-tick": "^1.1.0",
|
|
35
35
|
"once": "^1.4.0",
|
|
36
36
|
"semver": "^5.7.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@biomejs/biome": "^1.
|
|
40
|
-
"@types/mocha": "^10.0.
|
|
41
|
-
"@types/node": "^
|
|
39
|
+
"@biomejs/biome": "^1.9.4",
|
|
40
|
+
"@types/mocha": "^10.0.10",
|
|
41
|
+
"@types/node": "^22.10.1",
|
|
42
42
|
"cr": "^0.1.0",
|
|
43
43
|
"depcheck": "^1.4.7",
|
|
44
44
|
"is-version": "^0.2.1",
|
|
45
|
-
"
|
|
46
|
-
"node-
|
|
45
|
+
"mocha-compat": "^3.5.5",
|
|
46
|
+
"node-install-release": "^1.3.0",
|
|
47
|
+
"node-resolve-versions": "^1.0.0",
|
|
47
48
|
"node-version-utils": "^0.5.6",
|
|
48
|
-
"ts-dev-stack": "^0.
|
|
49
|
+
"ts-dev-stack": "^0.16.3"
|
|
49
50
|
},
|
|
50
51
|
"engines": {
|
|
51
52
|
"node": ">=0.8"
|
|
52
53
|
},
|
|
53
54
|
"tsds": {
|
|
54
|
-
"source": "src/index.
|
|
55
|
+
"source": "src/index.mjs",
|
|
55
56
|
"targets": [
|
|
56
57
|
"cjs"
|
|
57
58
|
]
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var constants = require("./constants");
|
|
3
|
-
var major = +process.versions.node.split(".")[0];
|
|
4
|
-
var spawnSync = major <= 7 ? require("../../assets/cross-spawn-6.0.5.js").sync : require("cross-spawn").sync;
|
|
5
|
-
module.exports = function spawnSyncCallback(command, args, options) {
|
|
6
|
-
options = options || {};
|
|
7
|
-
var syncOptions = Object.assign({}, options || {}, {
|
|
8
|
-
env: options.env || process.env,
|
|
9
|
-
stdio: "pipe",
|
|
10
|
-
encoding: "utf8"
|
|
11
|
-
});
|
|
12
|
-
var res = spawnSync(command, args, syncOptions);
|
|
13
|
-
// patch: early node on windows could return null
|
|
14
|
-
if (res.status === null) console.log("spawnSyncCallback null status code", res);
|
|
15
|
-
// res.status = res.status === null ? 0 : res.status;
|
|
16
|
-
// pipe if inherited
|
|
17
|
-
if (res.stdout && (options.stdout === "inherit" || options.stdio === "inherit")) {
|
|
18
|
-
process.stdout.write(res.stdout);
|
|
19
|
-
res.stdout = null;
|
|
20
|
-
}
|
|
21
|
-
if (res.stderr && (options.stderr === "inherit" || options.stdio === "inherit")) {
|
|
22
|
-
process.stderr.write(res.stderr);
|
|
23
|
-
res.stderr = null;
|
|
24
|
-
}
|
|
25
|
-
// process errors
|
|
26
|
-
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
27
|
-
if (res.stderr && res.stderr.length) {
|
|
28
|
-
err = err || new Error("stderr has content");
|
|
29
|
-
for(var key in res){
|
|
30
|
-
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
31
|
-
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString("utf8") : res[key];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (err) throw err;
|
|
35
|
-
return res;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
39
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
40
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
41
|
-
module.exports = exports.default;
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["spawnSyncCallback.js"],"sourcesContent":["const constants = require('./constants');\n\nconst major = +process.versions.node.split('.')[0];\nconst spawnSync = major <= 7 ? require('../../assets/cross-spawn-6.0.5.js').sync : require('cross-spawn').sync;\n\nmodule.exports = function spawnSyncCallback(command, args, options) {\n options = options || {};\n const syncOptions = Object.assign({}, options || {}, {\n env: options.env || process.env,\n stdio: 'pipe',\n encoding: 'utf8',\n });\n\n const res = spawnSync(command, args, syncOptions);\n\n // patch: early node on windows could return null\n if (res.status === null) console.log('spawnSyncCallback null status code', res);\n // res.status = res.status === null ? 0 : res.status;\n\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 // process errors\n let err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (res.stderr && res.stderr.length) {\n err = err || new Error('stderr has content');\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"],"names":["constants","require","major","process","versions","node","split","spawnSync","sync","module","exports","spawnSyncCallback","command","args","options","syncOptions","Object","assign","env","stdio","encoding","res","status","console","log","stdout","write","stderr","err","Error","length","key","spawnKeys","indexOf","Buffer","isBuffer","toString"],"mappings":";AAAA,IAAMA,YAAYC,QAAQ;AAE1B,IAAMC,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAClD,IAAMC,YAAYL,SAAS,IAAID,QAAQ,qCAAqCO,IAAI,GAAGP,QAAQ,eAAeO,IAAI;AAE9GC,OAAOC,OAAO,GAAG,SAASC,kBAAkBC,OAAO,EAAEC,IAAI,EAAEC,OAAO;IAChEA,UAAUA,WAAW,CAAC;IACtB,IAAMC,cAAcC,OAAOC,MAAM,CAAC,CAAC,GAAGH,WAAW,CAAC,GAAG;QACnDI,KAAKJ,QAAQI,GAAG,IAAIf,QAAQe,GAAG;QAC/BC,OAAO;QACPC,UAAU;IACZ;IAEA,IAAMC,MAAMd,UAAUK,SAASC,MAAME;IAErC,iDAAiD;IACjD,IAAIM,IAAIC,MAAM,KAAK,MAAMC,QAAQC,GAAG,CAAC,sCAAsCH;IAC3E,qDAAqD;IAErD,oBAAoB;IACpB,IAAIA,IAAII,MAAM,IAAKX,CAAAA,QAAQW,MAAM,KAAK,aAAaX,QAAQK,KAAK,KAAK,SAAQ,GAAI;QAC/EhB,QAAQsB,MAAM,CAACC,KAAK,CAACL,IAAII,MAAM;QAC/BJ,IAAII,MAAM,GAAG;IACf;IACA,IAAIJ,IAAIM,MAAM,IAAKb,CAAAA,QAAQa,MAAM,KAAK,aAAab,QAAQK,KAAK,KAAK,SAAQ,GAAI;QAC/EhB,QAAQwB,MAAM,CAACD,KAAK,CAACL,IAAIM,MAAM;QAC/BN,IAAIM,MAAM,GAAG;IACf;IAEA,iBAAiB;IACjB,IAAIC,MAAMP,IAAIC,MAAM,KAAK,IAAI,IAAIO,MAAM,AAAC,uBAAiC,OAAXR,IAAIC,MAAM,KAAM;IAC9E,IAAID,IAAIM,MAAM,IAAIN,IAAIM,MAAM,CAACG,MAAM,EAAE;QACnCF,MAAMA,OAAO,IAAIC,MAAM;QACvB,IAAK,IAAME,OAAOV,IAAK;YACrB,IAAIrB,UAAUgC,SAAS,CAACC,OAAO,CAACF,OAAO,GAAG;YAC1CH,GAAG,CAACG,IAAI,GAAGG,OAAOC,QAAQ,CAACd,GAAG,CAACU,IAAI,IAAIV,GAAG,CAACU,IAAI,CAACK,QAAQ,CAAC,UAAUf,GAAG,CAACU,IAAI;QAC7E;IACF;IACA,IAAIH,KAAK,MAAMA;IACf,OAAOP;AACT"}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
declare function _exports(command: any, args: any, options: any, callback: any): void;
|
|
2
|
-
declare namespace _exports {
|
|
3
|
-
let spawn: (command: any, args: any, options: any, callback: any) => void;
|
|
4
|
-
let sync: (command: any, args: any, options: any) => any;
|
|
5
|
-
}
|
|
6
|
-
export = _exports;
|
|
File without changes
|