cross-spawn-cb 2.5.2 → 2.5.3

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.
@@ -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 (isError(status)) {
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 err1 = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
70
- if (err1) {
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
- err1[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
69
+ exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
74
70
  }
75
71
  }
76
- err1 ? callback(err1) : callback(null, res);
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\nfunction isError(obj) {\n return Object.prototype.toString.call(obj) === '[object Error]';\n}\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\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'], (status: number | null, signal: NodeJS.Signals | null) => {\n if (isError(status)) {\n const err = status as unknown as SpawnError;\n if (err.code === 'OK') return; // ignore\n return callback(err);\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 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(options.encoding || 'utf8') : res[key];\n }\n }\n err ? callback(err 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","isError","obj","Object","prototype","toString","call","cp","options","callback","res","pid","output","stdout","stderr","status","signal","encoding","on","push","bind","oo","err","code","Buffer","concat","Error","key","spawnKeys","index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AAM,GAAGH,IAAIG,MAAM,CAACR,QAAQ,CAACG,QAAQS,QAAQ;QACtF;QACA,IAAIT,QAAQS,QAAQ,IAAIV,GAAGO,MAAM,EAAE;YACjCJ,IAAII,MAAM,GAAGU,OAAOC,MAAM,CAACX;YAC3B,IAAIN,QAAQS,QAAQ,KAAK,UAAUP,IAAII,MAAM,GAAGJ,IAAII,MAAM,CAACT,QAAQ,CAACG,QAAQS,QAAQ;QACtF;QACAP,IAAIE,MAAM,GAAG;YAAC;YAAMF,IAAIG,MAAM;YAAEH,IAAII,MAAM;SAAC;QAC3C,IAAIJ,IAAIK,MAAM,KAAK,MAAML,IAAIK,MAAM,GAAG,GAAG,iDAAiD;QAE1F,iBAAiB;QACjB,IAAMO,OAAMZ,IAAIK,MAAM,KAAK,IAAI,IAAIW,MAAM,AAAC,uBAAiC,OAAXhB,IAAIK,MAAM,KAAM;QAChF,IAAIO,MAAK;YACP,IAAK,IAAMK,OAAOjB,IAAK;gBACrB,IAAIkB,sBAAS,CAACC,OAAO,CAACF,OAAO,GAAG;gBAChCL,IAAG,CAACK,IAAI,GAAGH,OAAOM,QAAQ,CAACpB,GAAG,CAACiB,IAAI,IAAIjB,GAAG,CAACiB,IAAI,CAACtB,QAAQ,CAACG,QAAQS,QAAQ,IAAI,UAAUP,GAAG,CAACiB,IAAI;YACjG;QACF;QACAL,OAAMb,SAASa,QAAqBb,SAAS,MAAMC;IACrD;IAEA,aAAa;IACb,IAAIF,QAAQuB,KAAK,IAAK,CAAA,OAAOvB,QAAQuB,KAAK,KAAK,YAAYP,OAAOM,QAAQ,CAACtB,QAAQuB,KAAK,CAAA,GAAI;QAC1FxB,GAAGyB,KAAK,CAACC,GAAG,CAACzB,QAAQuB,KAAK;IAC5B;AACF"}
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) {\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;;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,MAAM,CAACX;YAC3B,IAAIN,QAAQS,QAAQ,KAAK,UAAUP,IAAII,MAAM,GAAGJ,IAAII,MAAM,CAACY,QAAQ,CAAClB,QAAQS,QAAQ;QACtF;QACAP,IAAIE,MAAM,GAAG;YAAC;YAAMF,IAAIG,MAAM;YAAEH,IAAII,MAAM;SAAC;QAC3C,IAAIJ,IAAIK,MAAM,KAAK,MAAML,IAAIK,MAAM,GAAG,GAAG,iDAAiD;QAE1F,iBAAiB;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"}
@@ -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 (isError(status)) {
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 err = res.status !== 0 ? new Error(`Non-zero exit code: ${res.status}`) : null;
55
- if (err) {
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
- err[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
54
+ exitErr[key] = Buffer.isBuffer(res[key]) ? res[key].toString(options.encoding || 'utf8') : res[key];
59
55
  }
60
56
  }
61
- err ? callback(err) : callback(null, res);
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\nfunction isError(obj) {\n return Object.prototype.toString.call(obj) === '[object Error]';\n}\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\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'], (status: number | null, signal: NodeJS.Signals | null) => {\n if (isError(status)) {\n const err = status as unknown as SpawnError;\n if (err.code === 'OK') return; // ignore\n return callback(err);\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 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(options.encoding || 'utf8') : res[key];\n }\n }\n err ? callback(err 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","isError","obj","Object","prototype","toString","call","worker","cp","options","callback","res","pid","output","stdout","stderr","status","signal","encoding","on","push","bind","err","code","Buffer","concat","Error","key","indexOf","isBuffer","input","stdin","end"],"mappings":"AAAA,OAAOA,QAAQ,SAAS;AACxB,SAASC,SAAS,QAAQ,kBAAkB;AAI5C,SAASC,QAAQC,GAAG;IAClB,OAAOC,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACJ,SAAS;AACjD;AAEA,eAAe,SAASK,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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,MAAM,GAAG,GAAG,iDAAiD;QAE1F,iBAAiB;QACjB,MAAMM,MAAMX,IAAIK,MAAM,KAAK,IAAI,IAAIU,MAAM,CAAC,oBAAoB,EAAEf,IAAIK,MAAM,EAAE,IAAI;QAChF,IAAIM,KAAK;YACP,IAAK,MAAMK,OAAOhB,IAAK;gBACrB,IAAIX,UAAU4B,OAAO,CAACD,OAAO,GAAG;gBAChCL,GAAG,CAACK,IAAI,GAAGH,OAAOK,QAAQ,CAAClB,GAAG,CAACgB,IAAI,IAAIhB,GAAG,CAACgB,IAAI,CAACtB,QAAQ,CAACI,QAAQS,QAAQ,IAAI,UAAUP,GAAG,CAACgB,IAAI;YACjG;QACF;QACAL,MAAMZ,SAASY,OAAqBZ,SAAS,MAAMC;IACrD;IAEA,aAAa;IACb,IAAIF,QAAQqB,KAAK,IAAK,CAAA,OAAOrB,QAAQqB,KAAK,KAAK,YAAYN,OAAOK,QAAQ,CAACpB,QAAQqB,KAAK,CAAA,GAAI;QAC1FtB,GAAGuB,KAAK,CAACC,GAAG,CAACvB,QAAQqB,KAAK;IAC5B;AACF"}
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) {\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,IAAI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EAAE,IAAI;QACpF,IAAIW,SAAS;YACX,IAAK,MAAME,OAAOlB,IAAK;gBACrB,IAAIL,UAAUwB,OAAO,CAACD,OAAO,GAAG;gBAChCF,OAAO,CAACE,IAAI,GAAGL,OAAOO,QAAQ,CAACpB,GAAG,CAACkB,IAAI,IAAIlB,GAAG,CAACkB,IAAI,CAACH,QAAQ,CAACjB,QAAQS,QAAQ,IAAI,UAAUP,GAAG,CAACkB,IAAI;YACrG;QACF;QACAF,UAAUjB,SAASiB,WAAyBjB,SAAS,MAAMC;IAC7D;IAEA,aAAa;IACb,IAAIF,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-spawn-cb",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",