cross-spawn-cb 2.5.2 → 3.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/spawn.d.cts +3 -1
- package/dist/cjs/spawn.d.ts +3 -1
- package/dist/cjs/spawn.js +2 -1
- package/dist/cjs/spawn.js.map +1 -1
- package/dist/cjs/types.d.cts +1 -1
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/workers/async.js +6 -10
- package/dist/cjs/workers/async.js.map +1 -1
- package/dist/esm/spawn.d.ts +3 -1
- package/dist/esm/spawn.js +2 -1
- package/dist/esm/spawn.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/workers/async.js +6 -10
- package/dist/esm/workers/async.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/spawn.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import spawnSync from './spawnSync.js';
|
|
2
2
|
import type { SpawnCallback, SpawnOptions, SpawnResult } from './types.js';
|
|
3
|
-
declare function spawn(command: string, args: string[],
|
|
3
|
+
declare function spawn(command: string, args: string[], callback: SpawnCallback): void;
|
|
4
|
+
declare function spawn(command: string, args: string[], options: SpawnOptions, callback: SpawnCallback): void;
|
|
5
|
+
declare function spawn(command: string, args: string[], options?: SpawnOptions): Promise<SpawnResult>;
|
|
4
6
|
declare namespace spawn {
|
|
5
7
|
var worker: typeof import("./workers/async.js").default;
|
|
6
8
|
var sync: typeof spawnSync;
|
package/dist/cjs/spawn.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import spawnSync from './spawnSync.js';
|
|
2
2
|
import type { SpawnCallback, SpawnOptions, SpawnResult } from './types.js';
|
|
3
|
-
declare function spawn(command: string, args: string[],
|
|
3
|
+
declare function spawn(command: string, args: string[], callback: SpawnCallback): void;
|
|
4
|
+
declare function spawn(command: string, args: string[], options: SpawnOptions, callback: SpawnCallback): void;
|
|
5
|
+
declare function spawn(command: string, args: string[], options?: SpawnOptions): Promise<SpawnResult>;
|
|
4
6
|
declare namespace spawn {
|
|
5
7
|
var worker: typeof import("./workers/async.js").default;
|
|
6
8
|
var sync: typeof spawnSync;
|
package/dist/cjs/spawn.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: function() {
|
|
8
|
-
return
|
|
8
|
+
return _default;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _crossSpawnts = /*#__PURE__*/ _interop_require_default(require("./crossSpawn.js"));
|
|
@@ -33,4 +33,5 @@ function spawn(command, args, options, callback) {
|
|
|
33
33
|
spawn.worker = _asyncts.default;
|
|
34
34
|
spawn.sync = _spawnSyncts.default;
|
|
35
35
|
spawn.crossSpawn = _crossSpawnts.default;
|
|
36
|
+
var _default = spawn;
|
|
36
37
|
/* 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/spawn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawn.ts"],"sourcesContent":["import crossSpawn from './crossSpawn.ts';\nimport spawnSync from './spawnSync.ts';\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types.ts';\nimport worker from './workers/async.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawn.ts"],"sourcesContent":["import crossSpawn from './crossSpawn.ts';\nimport spawnSync from './spawnSync.ts';\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types.ts';\nimport worker from './workers/async.ts';\n\nfunction spawn(command: string, args: string[], callback: SpawnCallback): void;\nfunction spawn(command: string, args: string[], options: SpawnOptions, callback: SpawnCallback): void;\nfunction spawn(command: string, args: string[], options?: SpawnOptions): Promise<SpawnResult>;\nfunction spawn(command: string, args: string[], options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): void | 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 worker(cp, options, callback);\n return new Promise((resolve, reject) => worker(cp, options as SpawnOptions, (err, res) => (err ? reject(err) : resolve(res))));\n}\nspawn.worker = worker;\nspawn.sync = spawnSync;\nspawn.crossSpawn = crossSpawn;\n\nexport default spawn;\n"],"names":["spawn","command","args","options","callback","cp","crossSpawn","worker","Promise","resolve","reject","err","res","sync","spawnSync"],"mappings":";;;;+BAuBA;;;eAAA;;;mEAvBuB;kEACD;8DAEH;;;;;;AAKnB,SAASA,MAAMC,OAAe,EAAEC,IAAc,EAAEC,OAAsC,EAAEC,QAAwB;IAC9G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtB,IAAME,KAAKC,IAAAA,qBAAU,EAACL,SAASC,MAAMC;IAErC,IAAI,OAAOC,aAAa,YAAY,OAAOG,IAAAA,gBAAM,EAACF,IAAIF,SAASC;IAC/D,OAAO,IAAII,QAAQ,SAACC,SAASC;eAAWH,IAAAA,gBAAM,EAACF,IAAIF,SAAyB,SAACQ,KAAKC;mBAASD,MAAMD,OAAOC,OAAOF,QAAQG;;;AACzH;AACAZ,MAAMO,MAAM,GAAGA,gBAAM;AACrBP,MAAMa,IAAI,GAAGC,oBAAS;AACtBd,MAAMM,UAAU,GAAGA,qBAAU;IAE7B,WAAeN"}
|
package/dist/cjs/types.d.cts
CHANGED
|
@@ -32,7 +32,7 @@ export interface SpawnError extends NotFoundError, SpawnResult {
|
|
|
32
32
|
}
|
|
33
33
|
export type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;
|
|
34
34
|
export interface Enoent {
|
|
35
|
-
hookChildProcess: (cp: ChildProcess, parsed: Parsed) =>
|
|
35
|
+
hookChildProcess: (cp: ChildProcess, parsed: Parsed) => void;
|
|
36
36
|
verifyENOENT: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
37
37
|
verifyENOENTSync: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
38
38
|
notFoundError: (cp: ChildProcess, parsed: Parsed) => NotFoundError;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface SpawnError extends NotFoundError, SpawnResult {
|
|
|
32
32
|
}
|
|
33
33
|
export type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;
|
|
34
34
|
export interface Enoent {
|
|
35
|
-
hookChildProcess: (cp: ChildProcess, parsed: Parsed) =>
|
|
35
|
+
hookChildProcess: (cp: ChildProcess, parsed: Parsed) => void;
|
|
36
36
|
verifyENOENT: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
37
37
|
verifyENOENTSync: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
38
38
|
notFoundError: (cp: ChildProcess, parsed: Parsed) => NotFoundError;
|
|
@@ -15,9 +15,6 @@ function _interop_require_default(obj) {
|
|
|
15
15
|
default: obj
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function isError(obj) {
|
|
19
|
-
return Object.prototype.toString.call(obj) === '[object Error]';
|
|
20
|
-
}
|
|
21
18
|
function worker(cp, options, callback) {
|
|
22
19
|
if (typeof options === 'function') {
|
|
23
20
|
callback = options;
|
|
@@ -41,9 +38,8 @@ function worker(cp, options, callback) {
|
|
|
41
38
|
(0, _onone.default)(cp, [
|
|
42
39
|
'error',
|
|
43
40
|
'close'
|
|
44
|
-
], function(status, signal) {
|
|
45
|
-
if (
|
|
46
|
-
var err = status;
|
|
41
|
+
], function(err, status, signal) {
|
|
42
|
+
if (err) {
|
|
47
43
|
if (err.code === 'OK') return; // ignore
|
|
48
44
|
return callback(err);
|
|
49
45
|
}
|
|
@@ -66,14 +62,14 @@ function worker(cp, options, callback) {
|
|
|
66
62
|
];
|
|
67
63
|
if (res.status === null) res.status = 0; // patch: early node on windows could return null
|
|
68
64
|
// process errors
|
|
69
|
-
var
|
|
70
|
-
if (
|
|
65
|
+
var exitErr = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
|
|
66
|
+
if (exitErr) {
|
|
71
67
|
for(var key in res){
|
|
72
68
|
if (_constantsts.spawnKeys.indexOf(key) < 0) continue;
|
|
73
|
-
|
|
69
|
+
exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
|
|
74
70
|
}
|
|
75
71
|
}
|
|
76
|
-
|
|
72
|
+
exitErr ? callback(exitErr) : callback(null, res);
|
|
77
73
|
});
|
|
78
74
|
// pipe input
|
|
79
75
|
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/async.ts"],"sourcesContent":["import oo from 'on-one';\nimport { spawnKeys } from '../constants.ts';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/async.ts"],"sourcesContent":["import oo from 'on-one';\nimport { spawnKeys } from '../constants.ts';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types.ts';\n\nexport default function worker(cp: ChildProcess, options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): void {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n // collect output\n const res = { pid: 0, output: [], stdout: null, stderr: null, status: null, signal: null } as SpawnResult;\n const stdout: Buffer[] = [];\n const stderr: Buffer[] = [];\n if (options.encoding && cp.stdout) cp.stdout.on('data', stdout.push.bind(stdout));\n if (options.encoding && cp.stderr) cp.stderr.on('data', stderr.push.bind(stderr));\n\n // some versions of node emit both an error and close\n oo(cp, ['error', 'close'], (err: Error | null, status: number | null, signal: NodeJS.Signals | null) => {\n if (err) {\n if ((err as SpawnError).code === 'OK') return; // ignore\n return callback(err as SpawnError);\n }\n\n // prepare result\n res.pid = cp.pid;\n res.status = status;\n res.signal = signal;\n if (options.encoding && cp.stdout) {\n res.stdout = Buffer.concat(stdout);\n if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);\n }\n if (options.encoding && cp.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 if (res.status === null) res.status = 0; // patch: early node on windows could return null\n\n // process errors\n const exitErr = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (exitErr) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];\n }\n }\n exitErr ? callback(exitErr as SpawnError) : callback(null, res);\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","res","pid","output","stdout","stderr","status","signal","encoding","on","push","bind","oo","err","code","Buffer","concat","toString","exitErr","Error","key","spawnKeys","indexOf","isBuffer","input","stdin","end"],"mappings":";;;;+BAKA;;;eAAwBA;;;4DALT;2BACW;;;;;;AAIX,SAASA,OAAOC,EAAgB,EAAEC,OAAsC,EAAEC,QAAwB;IAC/G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,iBAAiB;IACjB,IAAME,MAAM;QAAEC,KAAK;QAAGC,QAAQ,EAAE;QAAEC,QAAQ;QAAMC,QAAQ;QAAMC,QAAQ;QA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B;QACjB,IAAMY,UAAUjB,IAAIK,MAAM,KAAK,IAAI,IAAIa,MAAM,AAAC,uBAAiC,OAAXlB,IAAIK,MAAM,KAAM;QACpF,IAAIY,SAAS;YACX,IAAK,IAAME,OAAOnB,IAAK;gBACrB,IAAIoB,sBAAS,CAACC,OAAO,CAACF,OAAO,GAAG;gBAChCF,OAAO,CAACE,IAAI,GAAGL,OAAOQ,QAAQ,CAACtB,GAAG,CAACmB,IAAI,IAAInB,GAAG,CAACmB,IAAI,CAACH,QAAQ,CAAClB,QAAQS,QAAQ,IAAI,UAAUP,GAAG,CAACmB,IAAI;YACrG;QACF;QACAF,UAAUlB,SAASkB,WAAyBlB,SAAS,MAAMC;IAC7D;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"}
|
package/dist/esm/spawn.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import spawnSync from './spawnSync.js';
|
|
2
2
|
import type { SpawnCallback, SpawnOptions, SpawnResult } from './types.js';
|
|
3
|
-
declare function spawn(command: string, args: string[],
|
|
3
|
+
declare function spawn(command: string, args: string[], callback: SpawnCallback): void;
|
|
4
|
+
declare function spawn(command: string, args: string[], options: SpawnOptions, callback: SpawnCallback): void;
|
|
5
|
+
declare function spawn(command: string, args: string[], options?: SpawnOptions): Promise<SpawnResult>;
|
|
4
6
|
declare namespace spawn {
|
|
5
7
|
var worker: typeof import("./workers/async.js").default;
|
|
6
8
|
var sync: typeof spawnSync;
|
package/dist/esm/spawn.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crossSpawn from './crossSpawn.js';
|
|
2
2
|
import spawnSync from './spawnSync.js';
|
|
3
3
|
import worker from './workers/async.js';
|
|
4
|
-
|
|
4
|
+
function spawn(command, args, options, callback) {
|
|
5
5
|
if (typeof options === 'function') {
|
|
6
6
|
callback = options;
|
|
7
7
|
options = {};
|
|
@@ -14,3 +14,4 @@ export default function spawn(command, args, options, callback) {
|
|
|
14
14
|
spawn.worker = worker;
|
|
15
15
|
spawn.sync = spawnSync;
|
|
16
16
|
spawn.crossSpawn = crossSpawn;
|
|
17
|
+
export default spawn;
|
package/dist/esm/spawn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawn.ts"],"sourcesContent":["import crossSpawn from './crossSpawn.ts';\nimport spawnSync from './spawnSync.ts';\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types.ts';\nimport worker from './workers/async.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/spawn.ts"],"sourcesContent":["import crossSpawn from './crossSpawn.ts';\nimport spawnSync from './spawnSync.ts';\nimport type { SpawnCallback, SpawnOptions, SpawnResult } from './types.ts';\nimport worker from './workers/async.ts';\n\nfunction spawn(command: string, args: string[], callback: SpawnCallback): void;\nfunction spawn(command: string, args: string[], options: SpawnOptions, callback: SpawnCallback): void;\nfunction spawn(command: string, args: string[], options?: SpawnOptions): Promise<SpawnResult>;\nfunction spawn(command: string, args: string[], options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): void | 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 worker(cp, options, callback);\n return new Promise((resolve, reject) => worker(cp, options as SpawnOptions, (err, res) => (err ? reject(err) : resolve(res))));\n}\nspawn.worker = worker;\nspawn.sync = spawnSync;\nspawn.crossSpawn = crossSpawn;\n\nexport default spawn;\n"],"names":["crossSpawn","spawnSync","worker","spawn","command","args","options","callback","cp","Promise","resolve","reject","err","res","sync"],"mappings":"AAAA,OAAOA,gBAAgB,kBAAkB;AACzC,OAAOC,eAAe,iBAAiB;AAEvC,OAAOC,YAAY,qBAAqB;AAKxC,SAASC,MAAMC,OAAe,EAAEC,IAAc,EAAEC,OAAsC,EAAEC,QAAwB;IAC9G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtB,MAAME,KAAKR,WAAWI,SAASC,MAAMC;IAErC,IAAI,OAAOC,aAAa,YAAY,OAAOL,OAAOM,IAAIF,SAASC;IAC/D,OAAO,IAAIE,QAAQ,CAACC,SAASC,SAAWT,OAAOM,IAAIF,SAAyB,CAACM,KAAKC,MAASD,MAAMD,OAAOC,OAAOF,QAAQG;AACzH;AACAV,MAAMD,MAAM,GAAGA;AACfC,MAAMW,IAAI,GAAGb;AACbE,MAAMH,UAAU,GAAGA;AAEnB,eAAeG,MAAM"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface SpawnError extends NotFoundError, SpawnResult {
|
|
|
32
32
|
}
|
|
33
33
|
export type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;
|
|
34
34
|
export interface Enoent {
|
|
35
|
-
hookChildProcess: (cp: ChildProcess, parsed: Parsed) =>
|
|
35
|
+
hookChildProcess: (cp: ChildProcess, parsed: Parsed) => void;
|
|
36
36
|
verifyENOENT: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
37
37
|
verifyENOENTSync: (status: number, parsed: Parsed) => NotFoundError | null;
|
|
38
38
|
notFoundError: (cp: ChildProcess, parsed: Parsed) => NotFoundError;
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/types.ts"],"sourcesContent":["import type * as child_process from 'child_process';\n\nexport type ChildProcess = child_process.ChildProcess;\nexport interface SpawnOptions extends child_process.SpawnOptions {\n encoding?: BufferEncoding;\n env?: NodeJS.ProcessEnv;\n input?: string | Buffer;\n}\nexport interface SpawnSyncOptions extends child_process.SpawnSyncOptions {\n encoding?: BufferEncoding;\n env?: NodeJS.ProcessEnv;\n input?: string | Buffer;\n}\nexport type SpawnResult = child_process.SpawnSyncReturns<string | Buffer>;\n\nexport interface Parsed {\n command: string;\n args: string[];\n options: SpawnOptions | SpawnSyncOptions;\n file?: string | null;\n original?: {\n command: string;\n args: string[];\n };\n}\n\nexport interface NotFoundError extends Error {\n code?: string;\n errno?: string;\n syscall?: string;\n path?: string;\n spawnargs?: string[];\n}\nexport interface SpawnError extends NotFoundError, SpawnResult {}\n\nexport type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;\n\nexport interface Enoent {\n hookChildProcess: (cp: ChildProcess, parsed: Parsed) =>
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/types.ts"],"sourcesContent":["import type * as child_process from 'child_process';\n\nexport type ChildProcess = child_process.ChildProcess;\nexport interface SpawnOptions extends child_process.SpawnOptions {\n encoding?: BufferEncoding;\n env?: NodeJS.ProcessEnv;\n input?: string | Buffer;\n}\nexport interface SpawnSyncOptions extends child_process.SpawnSyncOptions {\n encoding?: BufferEncoding;\n env?: NodeJS.ProcessEnv;\n input?: string | Buffer;\n}\nexport type SpawnResult = child_process.SpawnSyncReturns<string | Buffer>;\n\nexport interface Parsed {\n command: string;\n args: string[];\n options: SpawnOptions | SpawnSyncOptions;\n file?: string | null;\n original?: {\n command: string;\n args: string[];\n };\n}\n\nexport interface NotFoundError extends Error {\n code?: string;\n errno?: string;\n syscall?: string;\n path?: string;\n spawnargs?: string[];\n}\nexport interface SpawnError extends NotFoundError, SpawnResult {}\n\nexport type SpawnCallback = (err?: SpawnError, res?: SpawnResult) => void;\n\nexport interface Enoent {\n hookChildProcess: (cp: ChildProcess, parsed: Parsed) => void;\n verifyENOENT: (status: number, parsed: Parsed) => NotFoundError | null;\n verifyENOENTSync: (status: number, parsed: Parsed) => NotFoundError | null;\n notFoundError: (cp: ChildProcess, parsed: Parsed) => NotFoundError;\n}\n"],"names":[],"mappings":"AAqCA,WAKC"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import oo from 'on-one';
|
|
2
2
|
import { spawnKeys } from '../constants.js';
|
|
3
|
-
function isError(obj) {
|
|
4
|
-
return Object.prototype.toString.call(obj) === '[object Error]';
|
|
5
|
-
}
|
|
6
3
|
export default function worker(cp, options, callback) {
|
|
7
4
|
if (typeof options === 'function') {
|
|
8
5
|
callback = options;
|
|
@@ -26,9 +23,8 @@ export default function worker(cp, options, callback) {
|
|
|
26
23
|
oo(cp, [
|
|
27
24
|
'error',
|
|
28
25
|
'close'
|
|
29
|
-
], (status, signal)=>{
|
|
30
|
-
if (
|
|
31
|
-
const err = status;
|
|
26
|
+
], (err, status, signal)=>{
|
|
27
|
+
if (err) {
|
|
32
28
|
if (err.code === 'OK') return; // ignore
|
|
33
29
|
return callback(err);
|
|
34
30
|
}
|
|
@@ -51,14 +47,14 @@ export default function worker(cp, options, callback) {
|
|
|
51
47
|
];
|
|
52
48
|
if (res.status === null) res.status = 0; // patch: early node on windows could return null
|
|
53
49
|
// process errors
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
50
|
+
const exitErr = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;
|
|
51
|
+
if (exitErr) {
|
|
56
52
|
for(const key in res){
|
|
57
53
|
if (spawnKeys.indexOf(key) < 0) continue;
|
|
58
|
-
|
|
54
|
+
exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
|
-
|
|
57
|
+
exitErr ? callback(exitErr) : callback(null, res);
|
|
62
58
|
});
|
|
63
59
|
// pipe input
|
|
64
60
|
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/async.ts"],"sourcesContent":["import oo from 'on-one';\nimport { spawnKeys } from '../constants.ts';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types.ts';\n\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/cross-spawn-cb/src/workers/async.ts"],"sourcesContent":["import oo from 'on-one';\nimport { spawnKeys } from '../constants.ts';\n\nimport type { ChildProcess, SpawnCallback, SpawnError, SpawnOptions, SpawnResult } from '../types.ts';\n\nexport default function worker(cp: ChildProcess, options?: SpawnOptions | SpawnCallback, callback?: SpawnCallback): void {\n if (typeof options === 'function') {\n callback = options;\n options = {};\n }\n options = options || {};\n\n // collect output\n const res = { pid: 0, output: [], stdout: null, stderr: null, status: null, signal: null } as SpawnResult;\n const stdout: Buffer[] = [];\n const stderr: Buffer[] = [];\n if (options.encoding && cp.stdout) cp.stdout.on('data', stdout.push.bind(stdout));\n if (options.encoding && cp.stderr) cp.stderr.on('data', stderr.push.bind(stderr));\n\n // some versions of node emit both an error and close\n oo(cp, ['error', 'close'], (err: Error | null, status: number | null, signal: NodeJS.Signals | null) => {\n if (err) {\n if ((err as SpawnError).code === 'OK') return; // ignore\n return callback(err as SpawnError);\n }\n\n // prepare result\n res.pid = cp.pid;\n res.status = status;\n res.signal = signal;\n if (options.encoding && cp.stdout) {\n res.stdout = Buffer.concat(stdout);\n if (options.encoding !== 'binary') res.stdout = res.stdout.toString(options.encoding);\n }\n if (options.encoding && cp.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 if (res.status === null) res.status = 0; // patch: early node on windows could return null\n\n // process errors\n const exitErr = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;\n if (exitErr) {\n for (const key in res) {\n if (spawnKeys.indexOf(key) < 0) continue;\n exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];\n }\n }\n exitErr ? callback(exitErr as SpawnError) : callback(null, res);\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":["oo","spawnKeys","worker","cp","options","callback","res","pid","output","stdout","stderr","status","signal","encoding","on","push","bind","err","code","Buffer","concat","toString","exitErr","Error","key","indexOf","isBuffer","input","stdin","end"],"mappings":"AAAA,OAAOA,QAAQ,SAAS;AACxB,SAASC,SAAS,QAAQ,kBAAkB;AAI5C,eAAe,SAASC,OAAOC,EAAgB,EAAEC,OAAsC,EAAEC,QAAwB;IAC/G,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IAEtB,iBAAiB;IACjB,MAAME,MAAM;QAAEC,KAAK;QAAGC,QAAQ,EAAE;QAAEC,QAAQ;QAAMC,QAAQ;QAAMC,QAAQ;QAAMC,QAAQ;IAAK;IACzF,MAAMH,SAAmB,EAAE;IAC3B,MAAMC,SAAmB,EAAE;IAC3B,IAAIN,QAAQS,QAAQ,IAAIV,GAAGM,MAAM,EAAEN,GAAGM,MAAM,CAACK,EAAE,CAAC,QAAQL,OAAOM,IAAI,CAACC,IAAI,CAACP;IACzE,IAAIL,QAAQS,QAAQ,IAAIV,GAAGO,MAAM,EAAEP,GAAGO,MAAM,CAACI,EAAE,CAAC,QAAQJ,OAAOK,IAAI,CAACC,IAAI,CAACN;IAEzE,qDAAqD;IACrDV,GAAGG,IAAI;QAAC;QAAS;KAAQ,EAAE,CAACc,KAAmBN,QAAuBC;QACpE,IAAIK,KAAK;YACP,IAAI,AAACA,IAAmBC,IAAI,KAAK,MAAM,QAAQ,SAAS;YACxD,OAAOb,SAASY;QAClB;QAEA,iBAAiB;QACjBX,IAAIC,GAAG,GAAGJ,GAAGI,GAAG;QAChBD,IAAIK,MAAM,GAAGA;QAC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CAACzB,QAAQuB,KAAK;IAC5B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cross-spawn-cb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Cross spawn with a completion callback",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cross-spawn",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"node-version-utils": "^1.0.2",
|
|
53
53
|
"pinkie-promise": "*",
|
|
54
54
|
"ts-dev-stack": "*",
|
|
55
|
-
"tsds-config": "
|
|
55
|
+
"tsds-config": "^1.0.4"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=0.8"
|