cross-spawn-cb 0.6.14 → 0.6.16
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.js +17 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/polyfills.js +24 -0
- package/dist/cjs/polyfills.js.map +1 -0
- package/dist/cjs/spawnCallback.js +80 -0
- package/dist/cjs/spawnCallback.js.map +1 -0
- package/dist/cjs/spawnSyncCallback.js +42 -0
- package/dist/cjs/spawnSyncCallback.js.map +1 -0
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/polyfills.d.ts +1 -0
- package/dist/types/spawnCallback.d.ts +2 -0
- package/dist/types/spawnSyncCallback.d.ts +2 -0
- package/package.json +27 -33
- package/lib/constants.js +0 -3
- package/lib/index.js +0 -5
- package/lib/polyfills.js +0 -19
- package/lib/spawnCallback.js +0 -75
- package/lib/spawnSyncCallback.js +0 -41
- /package/{lib → assets}/cross-spawn-6.0.5.js +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
spawnKeys: [
|
|
4
|
+
"pid",
|
|
5
|
+
"status",
|
|
6
|
+
"signal",
|
|
7
|
+
"stdout",
|
|
8
|
+
"stderr",
|
|
9
|
+
"output"
|
|
10
|
+
]
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require("./polyfills");
|
|
3
|
+
module.exports = require("./spawnCallback");
|
|
4
|
+
module.exports.spawn = require("./spawnCallback");
|
|
5
|
+
module.exports.sync = require("./spawnSyncCallback");
|
|
6
|
+
|
|
7
|
+
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
8
|
+
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
9
|
+
for (var key in exports) exports.default[key] = exports[key];
|
|
10
|
+
module.exports = exports.default;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["require('./polyfills');\n\nmodule.exports = require('./spawnCallback');\nmodule.exports.spawn = require('./spawnCallback');\nmodule.exports.sync = require('./spawnSyncCallback');\n"],"names":["require","module","exports","spawn","sync"],"mappings":";AAAAA,QAAQ;AAERC,OAAOC,OAAO,GAAGF,QAAQ;AACzBC,OAAOC,OAAO,CAACC,KAAK,GAAGH,QAAQ;AAC/BC,OAAOC,OAAO,CAACE,IAAI,GAAGJ,QAAQ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
if (!cp.spawnSync) {
|
|
10
|
+
var spawnCallback = path.join(__dirname, "spawnCallback.js");
|
|
11
|
+
var functionExec = null; // break dependencies
|
|
12
|
+
cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {
|
|
13
|
+
if (!functionExec) functionExec = require("function-exec-sync");
|
|
14
|
+
return functionExec({
|
|
15
|
+
callbacks: true
|
|
16
|
+
}, spawnCallback, cmd, args, options || {});
|
|
17
|
+
};
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["polyfills.js"],"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,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require("./polyfills");
|
|
3
|
+
var once = require("once");
|
|
4
|
+
var nextTick = require("next-tick");
|
|
5
|
+
var constants = require("./constants");
|
|
6
|
+
var major = +process.versions.node.split(".")[0];
|
|
7
|
+
var spawn = major <= 7 ? require("../../assets/cross-spawn-6.0.5.js").spawn : require("cross-spawn").spawn;
|
|
8
|
+
module.exports = function spawnCallback(command, args, options, callback) {
|
|
9
|
+
if (typeof options === "function") {
|
|
10
|
+
callback = options;
|
|
11
|
+
options = {};
|
|
12
|
+
}
|
|
13
|
+
options = options || {};
|
|
14
|
+
callback = once(callback);
|
|
15
|
+
var cp = spawn(command, args, options);
|
|
16
|
+
// collect output
|
|
17
|
+
var res = {
|
|
18
|
+
stdout: null,
|
|
19
|
+
stderr: null
|
|
20
|
+
};
|
|
21
|
+
if (options.encoding) {
|
|
22
|
+
if (cp.stdout) {
|
|
23
|
+
res.stdout = [];
|
|
24
|
+
cp.stdout.on("data", res.stdout.push.bind(res.stdout));
|
|
25
|
+
}
|
|
26
|
+
if (cp.stderr) {
|
|
27
|
+
res.stderr = [];
|
|
28
|
+
cp.stderr.on("data", res.stderr.push.bind(res.stderr));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// some versions of node emit both an error and close
|
|
32
|
+
cp.on("error", function error(err) {
|
|
33
|
+
err.code === "OK" || callback(err);
|
|
34
|
+
});
|
|
35
|
+
// done
|
|
36
|
+
cp.on("close", function(status, signal) {
|
|
37
|
+
nextTick(function closeNextTick() {
|
|
38
|
+
// prepare result
|
|
39
|
+
res.pid = cp.pid;
|
|
40
|
+
res.status = status;
|
|
41
|
+
res.signal = signal;
|
|
42
|
+
if (res.stdout) {
|
|
43
|
+
res.stdout = Buffer.concat(res.stdout);
|
|
44
|
+
if (options.encoding !== "buffer") res.stdout = res.stdout.toString(options.encoding);
|
|
45
|
+
}
|
|
46
|
+
if (res.stderr) {
|
|
47
|
+
res.stderr = Buffer.concat(res.stderr);
|
|
48
|
+
if (options.encoding !== "buffer") res.stderr = res.stderr.toString(options.encoding);
|
|
49
|
+
}
|
|
50
|
+
res.output = [
|
|
51
|
+
null,
|
|
52
|
+
res.stdout,
|
|
53
|
+
res.stderr
|
|
54
|
+
];
|
|
55
|
+
// patch: early node on windows could return null
|
|
56
|
+
if (res.status === null) console.log("spawnCallback null status code", res);
|
|
57
|
+
// res.status = res.status === null ? 0 : res.status;
|
|
58
|
+
// process errors
|
|
59
|
+
var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
60
|
+
if (res.stderr && res.stderr.length) {
|
|
61
|
+
err = err || new Error("stderr has content");
|
|
62
|
+
for(var key in res){
|
|
63
|
+
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
64
|
+
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString("utf8") : res[key];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
err ? callback(err) : callback(null, res);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
// pipe input
|
|
71
|
+
if (options.input && (typeof options.input === "string" || Buffer.isBuffer(options.input))) {
|
|
72
|
+
cp.stdin.end(options.input);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
77
|
+
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
78
|
+
for (var key in exports) exports.default[key] = exports[key];
|
|
79
|
+
module.exports = exports.default;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["spawnCallback.js"],"sourcesContent":["require('./polyfills');\nconst once = require('once');\nconst nextTick = require('next-tick');\nconst constants = require('./constants');\n\nconst 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 = function spawnCallback(command, args, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n callback = once(callback);\n\n const cp = spawn(command, args, options);\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) console.log('spawnCallback null status code', res);\n // res.status = res.status === null ? 0 : res.status;\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 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":["require","once","nextTick","constants","major","process","versions","node","split","spawn","module","exports","spawnCallback","command","args","options","callback","cp","res","stdout","stderr","encoding","on","push","bind","error","err","code","status","signal","closeNextTick","pid","Buffer","concat","toString","output","console","log","Error","length","key","spawnKeys","indexOf","isBuffer","input","stdin","end"],"mappings":"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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export let spawnKeys: string[];
|
|
@@ -0,0 +1,6 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cross-spawn-cb",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"description": "Cross spawn with a completion callback",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cross-spawn",
|
|
@@ -12,54 +12,48 @@
|
|
|
12
12
|
"url": "git@github.com:kmalakoff/cross-spawn-cb.git"
|
|
13
13
|
},
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"main": "
|
|
15
|
+
"main": "dist/cjs/index.js",
|
|
16
|
+
"types": "dist/types/index.d.ts",
|
|
16
17
|
"files": [
|
|
17
|
-
"
|
|
18
|
+
"dist",
|
|
19
|
+
"assets"
|
|
18
20
|
],
|
|
19
21
|
"scripts": {
|
|
20
|
-
"build": "",
|
|
21
|
-
"
|
|
22
|
-
"format": "
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"test:engines": "nvu engines npm test"
|
|
22
|
+
"build": "tsds build",
|
|
23
|
+
"deploy": "tsds deploy",
|
|
24
|
+
"format": "biome check --apply-unsafe src/ test/",
|
|
25
|
+
"test": "tsds test:node --timeout=40000",
|
|
26
|
+
"test:engines": "nvu engines tsds test:node --timeout=40000",
|
|
27
|
+
"version": "tsds version"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"buffer-v6-polyfill": "^1.0.5",
|
|
30
|
-
"core-js": "^3.
|
|
31
|
+
"core-js": "^3.35.1",
|
|
31
32
|
"cross-spawn": "^7.0.3",
|
|
32
|
-
"function-exec-sync": "^0.2.
|
|
33
|
+
"function-exec-sync": "^0.2.11",
|
|
33
34
|
"next-tick": "^1.1.0",
|
|
34
35
|
"once": "^1.4.0",
|
|
35
36
|
"semver": "^5.7.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
41
|
-
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
42
|
-
"@typescript-eslint/parser": "^5.32.0",
|
|
39
|
+
"@biomejs/biome": "^1.5.3",
|
|
40
|
+
"@types/mocha": "^10.0.6",
|
|
41
|
+
"@types/node": "^20.11.17",
|
|
43
42
|
"cr": "^0.1.0",
|
|
44
|
-
"depcheck": "^1.4.
|
|
45
|
-
"eslint": "^8.21.0",
|
|
46
|
-
"eslint-config-prettier": "^8.5.0",
|
|
47
|
-
"eslint-config-standard": "^17.0.0",
|
|
48
|
-
"eslint-plugin-import": "^2.26.0",
|
|
49
|
-
"eslint-plugin-promise": "^6.0.0",
|
|
43
|
+
"depcheck": "^1.4.7",
|
|
50
44
|
"is-version": "^0.2.1",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"node-version-utils": "^0.5.5",
|
|
56
|
-
"prettier": "^2.7.1",
|
|
57
|
-
"rollup": "^2.77.2",
|
|
58
|
-
"rollup-plugin-babel": "^4.4.0",
|
|
59
|
-
"rollup-plugin-commonjs": "^10.1.0",
|
|
60
|
-
"rollup-plugin-node-externals": "^4.1.1"
|
|
45
|
+
"node-install-release": "^0.4.8",
|
|
46
|
+
"node-resolve-versions": "^0.3.9",
|
|
47
|
+
"node-version-utils": "^0.5.6",
|
|
48
|
+
"ts-dev-stack": "^0.9.6"
|
|
61
49
|
},
|
|
62
50
|
"engines": {
|
|
63
51
|
"node": ">=0.8"
|
|
52
|
+
},
|
|
53
|
+
"tsds": {
|
|
54
|
+
"source": "src/index.js",
|
|
55
|
+
"targets": [
|
|
56
|
+
"cjs"
|
|
57
|
+
]
|
|
64
58
|
}
|
|
65
59
|
}
|
package/lib/constants.js
DELETED
package/lib/index.js
DELETED
package/lib/polyfills.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
require('core-js/actual/object/assign');
|
|
2
|
-
require('core-js/actual/object/keys');
|
|
3
|
-
require('core-js/actual/array/find');
|
|
4
|
-
require('buffer-v6-polyfill');
|
|
5
|
-
|
|
6
|
-
var path = require('path');
|
|
7
|
-
if (!path.delimiter) path.delimiter = process.platform === 'win32' ? ';' : ':';
|
|
8
|
-
|
|
9
|
-
var cp = require('child_process');
|
|
10
|
-
if (!cp.spawnSync) {
|
|
11
|
-
var spawnCallback = path.join(__dirname, 'spawnCallback.js');
|
|
12
|
-
|
|
13
|
-
var functionExec = null; // break dependencies
|
|
14
|
-
cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {
|
|
15
|
-
if (!functionExec) functionExec = require('function-exec-sync');
|
|
16
|
-
|
|
17
|
-
return functionExec({ callbacks: true }, spawnCallback, cmd, args, options || {});
|
|
18
|
-
};
|
|
19
|
-
}
|
package/lib/spawnCallback.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
require('./polyfills');
|
|
2
|
-
var once = require('once');
|
|
3
|
-
var nextTick = require('next-tick');
|
|
4
|
-
var constants = require('./constants');
|
|
5
|
-
|
|
6
|
-
var major = +process.versions.node.split('.')[0];
|
|
7
|
-
var spawn = major <= 7 ? require('./cross-spawn-6.0.5').spawn : require('cross-spawn').spawn;
|
|
8
|
-
|
|
9
|
-
module.exports = function spawnCallback(command, args, options, callback) {
|
|
10
|
-
if (typeof options === 'function') {
|
|
11
|
-
callback = options;
|
|
12
|
-
options = {};
|
|
13
|
-
}
|
|
14
|
-
options = options || {};
|
|
15
|
-
callback = once(callback);
|
|
16
|
-
|
|
17
|
-
var cp = spawn(command, args, options);
|
|
18
|
-
|
|
19
|
-
// collect output
|
|
20
|
-
var res = { stdout: null, stderr: null };
|
|
21
|
-
if (options.encoding) {
|
|
22
|
-
if (cp.stdout) {
|
|
23
|
-
res.stdout = [];
|
|
24
|
-
cp.stdout.on('data', res.stdout.push.bind(res.stdout));
|
|
25
|
-
}
|
|
26
|
-
if (cp.stderr) {
|
|
27
|
-
res.stderr = [];
|
|
28
|
-
cp.stderr.on('data', res.stderr.push.bind(res.stderr));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// some versions of node emit both an error and close
|
|
33
|
-
cp.on('error', function error(err) {
|
|
34
|
-
err.code === 'OK' || callback(err);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// done
|
|
38
|
-
cp.on('close', function (status, signal) {
|
|
39
|
-
nextTick(function closeNextTick() {
|
|
40
|
-
// prepare result
|
|
41
|
-
res.pid = cp.pid;
|
|
42
|
-
res.status = status;
|
|
43
|
-
res.signal = signal;
|
|
44
|
-
if (res.stdout) {
|
|
45
|
-
res.stdout = Buffer.concat(res.stdout);
|
|
46
|
-
if (options.encoding !== 'buffer') res.stdout = res.stdout.toString(options.encoding);
|
|
47
|
-
}
|
|
48
|
-
if (res.stderr) {
|
|
49
|
-
res.stderr = Buffer.concat(res.stderr);
|
|
50
|
-
if (options.encoding !== 'buffer') res.stderr = res.stderr.toString(options.encoding);
|
|
51
|
-
}
|
|
52
|
-
res.output = [null, res.stdout, res.stderr];
|
|
53
|
-
|
|
54
|
-
// patch: early node on windows could return null
|
|
55
|
-
if (res.status === null) console.log('spawnCallback null status code', res);
|
|
56
|
-
// res.status = res.status === null ? 0 : res.status;
|
|
57
|
-
|
|
58
|
-
// process errors
|
|
59
|
-
var err = res.status !== 0 ? new Error('Non-zero exit code: ' + res.status) : null;
|
|
60
|
-
if (res.stderr && res.stderr.length) {
|
|
61
|
-
err = err || new Error('stderr has content');
|
|
62
|
-
for (var key in res) {
|
|
63
|
-
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
64
|
-
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
err ? callback(err) : callback(null, res);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// pipe input
|
|
72
|
-
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
|
73
|
-
cp.stdin.end(options.input);
|
|
74
|
-
}
|
|
75
|
-
};
|
package/lib/spawnSyncCallback.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var constants = require('./constants');
|
|
2
|
-
|
|
3
|
-
var major = +process.versions.node.split('.')[0];
|
|
4
|
-
var spawnSync = major <= 7 ? require('./cross-spawn-6.0.5').sync : require('cross-spawn').sync;
|
|
5
|
-
|
|
6
|
-
module.exports = function spawnSyncCallback(command, args, options) {
|
|
7
|
-
options = options || {};
|
|
8
|
-
var syncOptions = Object.assign({}, options || {}, {
|
|
9
|
-
env: options.env || process.env,
|
|
10
|
-
stdio: 'pipe',
|
|
11
|
-
encoding: 'utf8',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
var res = spawnSync(command, args, syncOptions);
|
|
15
|
-
|
|
16
|
-
// patch: early node on windows could return null
|
|
17
|
-
if (res.status === null) console.log('spawnSyncCallback null status code', res);
|
|
18
|
-
// res.status = res.status === null ? 0 : res.status;
|
|
19
|
-
|
|
20
|
-
// pipe if inherited
|
|
21
|
-
if (res.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {
|
|
22
|
-
process.stdout.write(res.stdout);
|
|
23
|
-
res.stdout = null;
|
|
24
|
-
}
|
|
25
|
-
if (res.stderr && (options.stderr === 'inherit' || options.stdio === 'inherit')) {
|
|
26
|
-
process.stderr.write(res.stderr);
|
|
27
|
-
res.stderr = null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// process errors
|
|
31
|
-
var err = res.status !== 0 ? new Error('Non-zero exit code: ' + res.status) : null;
|
|
32
|
-
if (res.stderr && res.stderr.length) {
|
|
33
|
-
err = err || new Error('stderr has content');
|
|
34
|
-
for (var key in res) {
|
|
35
|
-
if (constants.spawnKeys.indexOf(key) < 0) continue;
|
|
36
|
-
err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (err) throw err;
|
|
40
|
-
return res;
|
|
41
|
-
};
|
|
File without changes
|