cross-spawn-cb 1.0.0 → 1.1.1

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 CHANGED
@@ -7,7 +7,7 @@ var assert = require('assert');
7
7
  var spawn = require('cross-spawn-cb');
8
8
 
9
9
  spawn('node', ['--version'], { stdio: 'inherit' }, function (err, res) {
10
- assert.ok(!err);
10
+ assert.ok(!err, err ? err.message : '');
11
11
  done();
12
12
  });
13
13
  ```
@@ -142,7 +142,7 @@ function requireMode() {
142
142
 
143
143
  var core;
144
144
 
145
- if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
145
+ if (process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE) || commonjsGlobal.TESTING_WINDOWS) {
146
146
  core = requireWindows();
147
147
  } else {
148
148
  core = requireMode();
@@ -201,7 +201,7 @@ function sync$1(path, options) {
201
201
 
202
202
  var which_1 = which$1;
203
203
  which$1.sync = whichSync;
204
- var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
204
+ var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE) || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
205
205
  var path$2 = require$$0__default$1["default"];
206
206
  var COLON = isWindows ? ';' : ':';
207
207
  var isexe = isexe_1;
@@ -465,7 +465,7 @@ var resolveCommand = resolveCommand_1;
465
465
  var escape = _escape;
466
466
  var readShebang = readShebang_1;
467
467
  var semver = require$$5__default["default"];
468
- var isWin$1 = process.platform === 'win32';
468
+ var isWin$1 = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
469
469
  var isExecutableRegExp = /\.(?:com|exe)$/i;
470
470
  var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i; // `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0
471
471
 
@@ -580,7 +580,7 @@ function parse$1(command, args, options) {
580
580
  }
581
581
 
582
582
  var parse_1 = parse$1;
583
- var isWin = process.platform === 'win32';
583
+ var isWin = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
584
584
 
585
585
  function notFoundError(original, syscall) {
586
586
  return Object.assign(new Error("".concat(syscall, " ").concat(original.command, " ENOENT")), {
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  module.exports = {
3
3
  spawnKeys: [
4
- "pid",
5
- "status",
6
- "signal",
7
- "stdout",
8
- "stderr",
9
- "output"
4
+ 'pid',
5
+ 'status',
6
+ 'signal',
7
+ 'stdout',
8
+ 'stderr',
9
+ 'output'
10
10
  ]
11
11
  };
12
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; }
@@ -1,16 +1,19 @@
1
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");
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) {
8
+ var isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);
9
+ path.delimiter = isWindows ? ';' : ':';
10
+ }
11
+ var cp = require('child_process');
9
12
  if (!cp.spawnSync) {
10
- var spawnCallback = path.join(__dirname, "spawnCallback.js");
13
+ var spawnCallback = path.join(__dirname, 'spawnCallback.js');
11
14
  var functionExec = null; // break dependencies
12
15
  cp.spawnSync = function spawnSyncPolyfill(cmd, args, options) {
13
- if (!functionExec) functionExec = require("function-exec-sync");
16
+ if (!functionExec) functionExec = require('function-exec-sync');
14
17
  return functionExec({
15
18
  callbacks: true
16
19
  }, spawnCallback, cmd, args, options || {});
@@ -1 +1 @@
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"}
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) {\n const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test(process.env.OSTYPE);\n path.delimiter = isWindows ? ';' : ':';\n}\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","isWindows","process","platform","test","env","OSTYPE","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,EAAE;IACnB,IAAMC,YAAYC,QAAQC,QAAQ,KAAK,WAAW,kBAAkBC,IAAI,CAACF,QAAQG,GAAG,CAACC,MAAM;IAC3FP,KAAKC,SAAS,GAAGC,YAAY,MAAM;AACrC;AAEA,IAAMM,KAAKT,QAAQ;AACnB,IAAI,CAACS,GAAGC,SAAS,EAAE;IACjB,IAAMC,gBAAgBV,KAAKW,IAAI,CAACC,WAAW;IAE3C,IAAIC,eAAe,MAAM,qBAAqB;IAC9CL,GAAGC,SAAS,GAAG,SAASK,kBAAkBC,GAAG,EAAEC,IAAI,EAAEC,OAAO;QAC1D,IAAI,CAACJ,cAAcA,eAAed,QAAQ;QAE1C,OAAOc,aAAa;YAAEK,WAAW;QAAK,GAAGR,eAAeK,KAAKC,MAAMC,WAAW,CAAC;IACjF;AACF"}
package/dist/cjs/spawn.js CHANGED
@@ -1,5 +1,5 @@
1
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;
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
4
  module.exports = spawn;
5
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; }
@@ -1,11 +1,11 @@
1
1
  "use strict";
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");
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
7
  function normalize(cp, options, callback) {
8
- if (typeof options === "function") {
8
+ if (typeof options === 'function') {
9
9
  callback = options;
10
10
  options = {};
11
11
  }
@@ -19,19 +19,19 @@ function normalize(cp, options, callback) {
19
19
  if (options.encoding) {
20
20
  if (cp.stdout) {
21
21
  res.stdout = [];
22
- cp.stdout.on("data", res.stdout.push.bind(res.stdout));
22
+ cp.stdout.on('data', res.stdout.push.bind(res.stdout));
23
23
  }
24
24
  if (cp.stderr) {
25
25
  res.stderr = [];
26
- cp.stderr.on("data", res.stderr.push.bind(res.stderr));
26
+ cp.stderr.on('data', res.stderr.push.bind(res.stderr));
27
27
  }
28
28
  }
29
29
  // some versions of node emit both an error and close
30
- cp.on("error", function error(err) {
31
- err.code === "OK" || callback(err);
30
+ cp.on('error', function error(err) {
31
+ err.code === 'OK' || callback(err);
32
32
  });
33
33
  // done
34
- cp.on("close", function(status, signal) {
34
+ cp.on('close', function(status, signal) {
35
35
  nextTick(function closeNextTick() {
36
36
  // prepare result
37
37
  res.pid = cp.pid;
@@ -39,11 +39,11 @@ function normalize(cp, options, callback) {
39
39
  res.signal = signal;
40
40
  if (res.stdout) {
41
41
  res.stdout = Buffer.concat(res.stdout);
42
- if (options.encoding !== "buffer") res.stdout = res.stdout.toString(options.encoding);
42
+ if (options.encoding !== 'buffer') res.stdout = res.stdout.toString(options.encoding);
43
43
  }
44
44
  if (res.stderr) {
45
45
  res.stderr = Buffer.concat(res.stderr);
46
- if (options.encoding !== "buffer") res.stderr = res.stderr.toString(options.encoding);
46
+ if (options.encoding !== 'buffer') res.stderr = res.stderr.toString(options.encoding);
47
47
  }
48
48
  res.output = [
49
49
  null,
@@ -51,27 +51,25 @@ function normalize(cp, options, callback) {
51
51
  res.stderr
52
52
  ];
53
53
  // patch: early node on windows could return null
54
- if (res.status === null) console.log("spawnCallback null status code", res);
55
- // res.status = res.status === null ? 0 : res.status;
54
+ if (res.status === null) res.status = 0;
56
55
  // process errors
57
56
  var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
58
- if (res.stderr && res.stderr.length) {
59
- err = err || new Error("stderr has content");
57
+ if (err) {
60
58
  for(var key in res){
61
59
  if (constants.spawnKeys.indexOf(key) < 0) continue;
62
- err[key] = Buffer.isBuffer(res[key]) ? res[key].toString("utf8") : res[key];
60
+ err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
63
61
  }
64
62
  }
65
63
  err ? callback(err) : callback(null, res);
66
64
  });
67
65
  });
68
66
  // pipe input
69
- if (options.input && (typeof options.input === "string" || Buffer.isBuffer(options.input))) {
67
+ if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
70
68
  cp.stdin.end(options.input);
71
69
  }
72
70
  }
73
71
  function spawnCallback(command, args, options, callback) {
74
- if (typeof options === "function") {
72
+ if (typeof options === 'function') {
75
73
  callback = options;
76
74
  options = {};
77
75
  }
@@ -1 +1 @@
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) 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\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","console","log","Error","length","key","spawnKeys","indexOf","isBuffer","input","stdin","end","spawnCallback","command","args","module","exports"],"mappings":";AAAAA,QAAQ;AACR,IAAMC,OAAO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jCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWP,KAAKO;IAChB,IAAMF,KAAKF,MAAMmC,SAASC,MAAMjC;IAChC,OAAOF,UAAUC,IAAIC,SAASC;AAChC;AAEAiC,OAAOC,OAAO,GAAGJ;AACjBG,OAAOC,OAAO,CAACrC,SAAS,GAAGA"}
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":";AAAAA,QAAQ;AACR,IAAMC,OAAOD,QAAQ;AACrB,IAAME,WAAWF,QAAQ;AACzB,IAAMG,YAAYH,QAAQ;AAC1B,IAAMI,QAAQJ,QAAQ;AAEtB,SAASK,UAAUC,EAAE,EAAEC,OAAO,EAAEC,QAAQ;IACtC,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWP,KAAKO;IAEhB,iBAAiB;IACjB,IAAMC,MAAM;QAAEC,QAAQ;QAAMC,QAAQ;IAAK;IACzC,IAAIJ,QAAQK,QAAQ,EAAE;QACpB,IAAIN,GAAGI,MAAM,EAAE;YACbD,IAAIC,MAAM,GAAG,EAAE;YACfJ,GAAGI,MAAM,CAACG,EAAE,CAAC,QAAQJ,IAAIC,MAAM,CAACI,IAAI,CAACC,IAAI,CAACN,IAAIC,MAAM;QACtD;QACA,IAAIJ,GAAGK,MAAM,EAAE;YACbF,IAAIE,MAAM,GAAG,EAAE;YACfL,GAAGK,MAAM,CAACE,EAAE,CAAC,QAAQJ,IAAIE,MAAM,CAACG,IAAI,CAACC,IAAI,CAACN,IAAIE,MAAM;QACtD;IACF;IAEA,qDAAqD;IACrDL,GAAGO,EAAE,CAAC,SAAS,SAASG,MAAMC,GAAG;QAC/B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,MAAMC;QACvC;IACF;IAEA,aAAa;IACb,IAAIF,QAAQyB,KAAK,IAAK,CAAA,OAAOzB,QAAQyB,KAAK,KAAK,YAAYT,OAAOQ,QAAQ,CAACxB,QAAQyB,KAAK,CAAA,GAAI;QAC1F1B,GAAG2B,KAAK,CAACC,GAAG,CAAC3B,QAAQyB,KAAK;IAC5B;AACF;AAEA,SAASG,cAAcC,OAAO,EAAEC,IAAI,EAAE9B,OAAO,EAAEC,QAAQ;IACrD,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU,CAAC;IACb;IACAA,UAAUA,WAAW,CAAC;IACtBC,WAAWP,KAAKO;IAChB,IAAMF,KAAKF,MAAMgC,SAASC,MAAM9B;IAChC,OAAOF,UAAUC,IAAIC,SAASC;AAChC;AAEA8B,OAAOC,OAAO,GAAGJ;AACjBG,OAAOC,OAAO,CAAClC,SAAS,GAAGA"}
@@ -1,26 +1,24 @@
1
1
  "use strict";
2
- var constants = require("./constants");
3
- var spawn = require("./spawn");
2
+ var constants = require('./constants');
3
+ var spawn = require('./spawn');
4
4
  function normalize(res, options) {
5
- // patch: early node on windows could return null
6
- if (res.status === null) console.log("spawnCallbackSync null status code", res);
7
- // res.status = res.status === null ? 0 : res.status;
8
5
  // pipe if inherited
9
- if (res.stdout && (options.stdout === "inherit" || options.stdio === "inherit")) {
6
+ if (res.stdout && (options.stdout === 'inherit' || options.stdio === 'inherit')) {
10
7
  process.stdout.write(res.stdout);
11
8
  res.stdout = null;
12
9
  }
13
- if (res.stderr && (options.stderr === "inherit" || options.stdio === "inherit")) {
10
+ if (res.stderr && (options.stderr === 'inherit' || options.stdio === 'inherit')) {
14
11
  process.stderr.write(res.stderr);
15
12
  res.stderr = null;
16
13
  }
14
+ // patch: early node on windows could return null
15
+ if (res.status === null) res.status = 0;
17
16
  // process errors
18
17
  var err = res.status !== 0 ? new Error("Non-zero exit code: ".concat(res.status)) : null;
19
- if (res.stderr && res.stderr.length) {
20
- err = err || new Error("stderr has content");
18
+ if (err) {
21
19
  for(var key in res){
22
20
  if (constants.spawnKeys.indexOf(key) < 0) continue;
23
- err[key] = Buffer.isBuffer(res[key]) ? res[key].toString("utf8") : res[key];
21
+ err[key] = Buffer.isBuffer(res[key]) ? res[key].toString('utf8') : res[key];
24
22
  }
25
23
  }
26
24
  if (err) throw err;
@@ -30,8 +28,8 @@ function spawnCallbackSync(command, args, options) {
30
28
  options = options || {};
31
29
  var syncOptions = Object.assign({}, options || {}, {
32
30
  env: options.env || process.env,
33
- stdio: "pipe",
34
- encoding: "utf8"
31
+ stdio: 'pipe',
32
+ encoding: 'utf8'
35
33
  });
36
34
  var res = spawn.sync(command, args, syncOptions);
37
35
  return normalize(res, options);
@@ -1 +1 @@
1
- {"version":3,"sources":["spawnCallbackSync.js"],"sourcesContent":["const constants = require('./constants');\nconst spawn = require('./spawn');\n\nfunction normalize(res, options) {\n // patch: early node on windows could return null\n if (res.status === null) console.log('spawnCallbackSync 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\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","status","console","log","stdout","stdio","process","write","stderr","err","Error","length","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,iDAAiD;IACjD,IAAID,IAAIE,MAAM,KAAK,MAAMC,QAAQC,GAAG,CAAC,sCAAsCJ;IAC3E,qDAAqD;IAErD,oBAAoB;IACpB,IAAIA,IAAIK,MAAM,IAAKJ,CAAAA,QAAQI,MAAM,KAAK,aAAaJ,QAAQK,KAAK,KAAK,SAAQ,GAAI;QAC/EC,QAAQF,MAAM,CAACG,KAAK,CAACR,IAAIK,MAAM;QAC/BL,IAAIK,MAAM,GAAG;IACf;IACA,IAAIL,IAAIS,MAAM,IAAKR,CAAAA,QAAQQ,MAAM,KAAK,aAAaR,QAAQK,KAAK,KAAK,SAAQ,GAAI;QAC/EC,QAAQE,MAAM,CAACD,KAAK,CAACR,IAAIS,MAAM;QAC/BT,IAAIS,MAAM,GAAG;IACf;IAEA,iBAAiB;IACjB,IAAIC,MAAMV,IAAIE,MAAM,KAAK,IAAI,IAAIS,MAAM,AAAC,uBAAiC,OAAXX,IAAIE,MAAM,KAAM;IAC9E,IAAIF,IAAIS,MAAM,IAAIT,IAAIS,MAAM,CAACG,MAAM,EAAE;QACnCF,MAAMA,OAAO,IAAIC,MAAM;QACvB,IAAK,IAAME,OAAOb,IAAK;YACrB,IAAIJ,UAAUkB,SAAS,CAACC,OAAO,CAACF,OAAO,GAAG;YAC1CH,GAAG,CAACG,IAAI,GAAGG,OAAOC,QAAQ,CAACjB,GAAG,CAACa,IAAI,IAAIb,GAAG,CAACa,IAAI,CAACK,QAAQ,CAAC,UAAUlB,GAAG,CAACa,IAAI;QAC7E;IACF;IACA,IAAIH,KAAK,MAAMA;IACf,OAAOV;AACT;AAEA,SAASmB,kBAAkBC,OAAO,EAAEC,IAAI,EAAEpB,OAAO;IAC/CA,UAAUA,WAAW,CAAC;IAEtB,IAAMqB,cAAcC,OAAOC,MAAM,CAAC,CAAC,GAAGvB,WAAW,CAAC,GAAG;QACnDwB,KAAKxB,QAAQwB,GAAG,IAAIlB,QAAQkB,GAAG;QAC/BnB,OAAO;QACPoB,UAAU;IACZ;IACA,IAAM1B,MAAMF,MAAM6B,IAAI,CAACP,SAASC,MAAMC;IAEtC,OAAOvB,UAAUC,KAAKC;AACxB;AAEA2B,OAAOC,OAAO,GAAGV;AACjBS,OAAOC,OAAO,CAAC9B,SAAS,GAAGA"}
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","spawnCallbackS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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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-spawn-cb",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",
@@ -30,7 +30,7 @@
30
30
  "buffer-v6-polyfill": "^1.0.5",
31
31
  "core-js": "^3.39.0",
32
32
  "cross-spawn": "^7.0.6",
33
- "function-exec-sync": "^0.2.11",
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"
@@ -38,15 +38,15 @@
38
38
  "devDependencies": {
39
39
  "@biomejs/biome": "^1.9.4",
40
40
  "@types/mocha": "^10.0.10",
41
- "@types/node": "^22.9.2",
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
- "mocha-compat": "^3.5.5",
46
- "node-install-release": "^1.1.1",
47
- "node-resolve-versions": "^0.3.10",
48
- "node-version-utils": "^0.5.6",
49
- "ts-dev-stack": "^0.15.8"
45
+ "mocha-compat": "^3.6.1",
46
+ "node-install-release": "^1.4.0",
47
+ "node-resolve-versions": "^1.0.0",
48
+ "node-version-utils": "^1.0.0",
49
+ "ts-dev-stack": "^0.17.0"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=0.8"