cross-spawn-cb 0.5.13 → 0.6.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/LICENSE CHANGED
@@ -42,35 +42,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
42
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
43
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44
44
  THE SOFTWARE.
45
-
46
- ---------------path-key-----------------------
47
- MIT License
48
-
49
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
50
-
51
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
52
-
53
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
54
-
55
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
56
-
57
- ---------------spawn-sync-----------------------
58
- Copyright (c) 2014 Forbes Lindesay
59
-
60
- Permission is hereby granted, free of charge, to any person obtaining a copy
61
- of this software and associated documentation files (the "Software"), to deal
62
- in the Software without restriction, including without limitation the rights
63
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
64
- copies of the Software, and to permit persons to whom the Software is
65
- furnished to do so, subject to the following conditions:
66
-
67
- The above copyright notice and this permission notice shall be included in
68
- all copies or substantial portions of the Software.
69
-
70
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
76
- THE SOFTWARE.
@@ -1,9 +1,22 @@
1
1
  'use strict';
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
+ function _typeof(obj) {
4
+ '@babel/helpers - typeof';
5
+ return (
6
+ (_typeof =
7
+ 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
8
+ ? function (obj) {
9
+ return typeof obj;
10
+ }
11
+ : function (obj) {
12
+ return obj && 'function' == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? 'symbol' : typeof obj;
13
+ }),
14
+ _typeof(obj)
15
+ );
16
+ }
4
17
 
5
18
  Object.defineProperty(exports, '__esModule', {
6
- value: true
19
+ value: true,
7
20
  });
8
21
 
9
22
  var require$$0$2 = require('child_process');
@@ -15,25 +28,36 @@ var require$$1 = require('util');
15
28
  var require$$0$1 = require('path');
16
29
 
17
30
  function _interopDefaultLegacy(e) {
18
- return e && _typeof(e) === 'object' && 'default' in e ? e : {
19
- 'default': e
20
- };
31
+ return e && _typeof(e) === 'object' && 'default' in e
32
+ ? e
33
+ : {
34
+ default: e,
35
+ };
21
36
  }
22
37
 
23
- var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
38
+ var require$$0__default$2 = /*#__PURE__*/ _interopDefaultLegacy(require$$0$2);
24
39
 
25
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
40
+ var require$$0__default = /*#__PURE__*/ _interopDefaultLegacy(require$$0);
26
41
 
27
- var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
42
+ var require$$1__default = /*#__PURE__*/ _interopDefaultLegacy(require$$1);
28
43
 
29
- var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
44
+ var require$$0__default$1 = /*#__PURE__*/ _interopDefaultLegacy(require$$0$1);
30
45
 
31
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
46
+ var commonjsGlobal =
47
+ typeof globalThis !== 'undefined'
48
+ ? globalThis
49
+ : typeof window !== 'undefined'
50
+ ? window
51
+ : typeof global !== 'undefined'
52
+ ? global
53
+ : typeof self !== 'undefined'
54
+ ? self
55
+ : {};
32
56
  var crossSpawn = {
33
- exports: {}
57
+ exports: {},
34
58
  };
35
59
  var map = {
36
- exports: {}
60
+ exports: {},
37
61
  };
38
62
  var pseudomap;
39
63
  var hasRequiredPseudomap;
@@ -45,16 +69,21 @@ function requirePseudomap() {
45
69
  pseudomap = PseudoMap;
46
70
 
47
71
  function PseudoMap(set) {
48
- if (!(this instanceof PseudoMap)) // whyyyyyyy
72
+ if (!(this instanceof PseudoMap))
73
+ // whyyyyyyy
49
74
  throw new TypeError("Constructor PseudoMap requires 'new'");
50
75
  this.clear();
51
76
 
52
77
  if (set) {
53
- if (set instanceof PseudoMap || typeof Map === 'function' && set instanceof Map) set.forEach(function (value, key) {
54
- this.set(key, value);
55
- }, this);else if (Array.isArray(set)) set.forEach(function (kv) {
56
- this.set(kv[0], kv[1]);
57
- }, this);else throw new TypeError('invalid argument');
78
+ if (set instanceof PseudoMap || (typeof Map === 'function' && set instanceof Map))
79
+ set.forEach(function (value, key) {
80
+ this.set(key, value);
81
+ }, this);
82
+ else if (Array.isArray(set))
83
+ set.forEach(function (kv) {
84
+ this.set(kv[0], kv[1]);
85
+ }, this);
86
+ else throw new TypeError('invalid argument');
58
87
  }
59
88
  }
60
89
 
@@ -78,7 +107,7 @@ function requirePseudomap() {
78
107
  set(this._data, k, v);
79
108
  };
80
109
 
81
- PseudoMap.prototype["delete"] = function (k) {
110
+ PseudoMap.prototype['delete'] = function (k) {
82
111
  var res = find(this._data, k);
83
112
 
84
113
  if (res) {
@@ -94,7 +123,7 @@ function requirePseudomap() {
94
123
  value: data,
95
124
  enumerable: false,
96
125
  configurable: true,
97
- writable: false
126
+ writable: false,
98
127
  });
99
128
  };
100
129
 
@@ -104,16 +133,18 @@ function requirePseudomap() {
104
133
  },
105
134
  set: function set(n) {},
106
135
  enumerable: true,
107
- configurable: true
136
+ configurable: true,
108
137
  });
109
138
 
110
- PseudoMap.prototype.values = PseudoMap.prototype.keys = PseudoMap.prototype.entries = function () {
111
- throw new Error('iterators are not implemented in this version');
112
- }; // Either identical, or both NaN
113
-
139
+ PseudoMap.prototype.values =
140
+ PseudoMap.prototype.keys =
141
+ PseudoMap.prototype.entries =
142
+ function () {
143
+ throw new Error('iterators are not implemented in this version');
144
+ }; // Either identical, or both NaN
114
145
 
115
146
  function same(a, b) {
116
- return a === b || a !== a && b !== b;
147
+ return a === b || (a !== a && b !== b);
117
148
  }
118
149
 
119
150
  function Entry(k, v, i) {
@@ -359,7 +390,7 @@ Yallist$1.prototype.map = function (fn, thisp) {
359
390
  thisp = thisp || this;
360
391
  var res = new Yallist$1();
361
392
 
362
- for (var walker = this.head; walker !== null;) {
393
+ for (var walker = this.head; walker !== null; ) {
363
394
  res.push(fn.call(thisp, walker.value, this));
364
395
  walker = walker.next;
365
396
  }
@@ -371,7 +402,7 @@ Yallist$1.prototype.mapReverse = function (fn, thisp) {
371
402
  thisp = thisp || this;
372
403
  var res = new Yallist$1();
373
404
 
374
- for (var walker = this.tail; walker !== null;) {
405
+ for (var walker = this.tail; walker !== null; ) {
375
406
  res.push(fn.call(thisp, walker.value, this));
376
407
  walker = walker.prev;
377
408
  }
@@ -581,7 +612,7 @@ var lruCache = LRUCache; // This will be a proper iterable 'Map' in engines that
581
612
  // or a fakey-fake PseudoMap in older versions.
582
613
 
583
614
  var Map$1 = map.exports;
584
- var util = require$$1__default["default"]; // A linked list to keep track of recently-used-ness
615
+ var util = require$$1__default['default']; // A linked list to keep track of recently-used-ness
585
616
 
586
617
  var Yallist = yallist; // use symbols if possible, otherwise just _props
587
618
 
@@ -619,7 +650,6 @@ function naiveLength() {
619
650
  // cache is a Map (or PseudoMap) that matches the keys to
620
651
  // the Yallist.Node object.
621
652
 
622
-
623
653
  function LRUCache(options) {
624
654
  if (!(this instanceof LRUCache)) {
625
655
  return new LRUCache(options);
@@ -627,7 +657,7 @@ function LRUCache(options) {
627
657
 
628
658
  if (typeof options === 'number') {
629
659
  options = {
630
- max: options
660
+ max: options,
631
661
  };
632
662
  }
633
663
 
@@ -635,7 +665,7 @@ function LRUCache(options) {
635
665
  options = {};
636
666
  }
637
667
 
638
- var max = this[MAX] = options.max; // Kind of weird to have a default max of Infinity, but oh well.
668
+ var max = (this[MAX] = options.max); // Kind of weird to have a default max of Infinity, but oh well.
639
669
 
640
670
  if (!max || !(typeof max === 'number') || max <= 0) {
641
671
  this[MAX] = Infinity;
@@ -655,7 +685,6 @@ function LRUCache(options) {
655
685
  this.reset();
656
686
  } // resize the cache when the max changes.
657
687
 
658
-
659
688
  Object.defineProperty(LRUCache.prototype, 'max', {
660
689
  set: function set(mL) {
661
690
  if (!mL || !(typeof mL === 'number') || mL <= 0) {
@@ -668,7 +697,7 @@ Object.defineProperty(LRUCache.prototype, 'max', {
668
697
  get: function get() {
669
698
  return this[MAX];
670
699
  },
671
- enumerable: true
700
+ enumerable: true,
672
701
  });
673
702
  Object.defineProperty(LRUCache.prototype, 'allowStale', {
674
703
  set: function set(allowStale) {
@@ -677,7 +706,7 @@ Object.defineProperty(LRUCache.prototype, 'allowStale', {
677
706
  get: function get() {
678
707
  return this[ALLOW_STALE];
679
708
  },
680
- enumerable: true
709
+ enumerable: true,
681
710
  });
682
711
  Object.defineProperty(LRUCache.prototype, 'maxAge', {
683
712
  set: function set(mA) {
@@ -691,7 +720,7 @@ Object.defineProperty(LRUCache.prototype, 'maxAge', {
691
720
  get: function get() {
692
721
  return this[MAX_AGE];
693
722
  },
694
- enumerable: true
723
+ enumerable: true,
695
724
  }); // resize the cache when the lengthCalculator changes.
696
725
 
697
726
  Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
@@ -714,25 +743,25 @@ Object.defineProperty(LRUCache.prototype, 'lengthCalculator', {
714
743
  get: function get() {
715
744
  return this[LENGTH_CALCULATOR];
716
745
  },
717
- enumerable: true
746
+ enumerable: true,
718
747
  });
719
748
  Object.defineProperty(LRUCache.prototype, 'length', {
720
749
  get: function get() {
721
750
  return this[LENGTH];
722
751
  },
723
- enumerable: true
752
+ enumerable: true,
724
753
  });
725
754
  Object.defineProperty(LRUCache.prototype, 'itemCount', {
726
755
  get: function get() {
727
756
  return this[LRU_LIST].length;
728
757
  },
729
- enumerable: true
758
+ enumerable: true,
730
759
  });
731
760
 
732
761
  LRUCache.prototype.rforEach = function (fn, thisp) {
733
762
  thisp = thisp || this;
734
763
 
735
- for (var walker = this[LRU_LIST].tail; walker !== null;) {
764
+ for (var walker = this[LRU_LIST].tail; walker !== null; ) {
736
765
  var prev = walker.prev;
737
766
  forEachStep(this, fn, walker, thisp);
738
767
  walker = prev;
@@ -758,7 +787,7 @@ function forEachStep(self, fn, node, thisp) {
758
787
  LRUCache.prototype.forEach = function (fn, thisp) {
759
788
  thisp = thisp || this;
760
789
 
761
- for (var walker = this[LRU_LIST].head; walker !== null;) {
790
+ for (var walker = this[LRU_LIST].head; walker !== null; ) {
762
791
  var next = walker.next;
763
792
  forEachStep(this, fn, walker, thisp);
764
793
  walker = next;
@@ -797,12 +826,14 @@ LRUCache.prototype.dump = function () {
797
826
  return {
798
827
  k: hit.key,
799
828
  v: hit.value,
800
- e: hit.now + (hit.maxAge || 0)
829
+ e: hit.now + (hit.maxAge || 0),
801
830
  };
802
831
  }
803
- }, this).toArray().filter(function (h) {
804
- return h;
805
- });
832
+ }, this)
833
+ .toArray()
834
+ .filter(function (h) {
835
+ return h;
836
+ });
806
837
  };
807
838
 
808
839
  LRUCache.prototype.dumpLru = function () {
@@ -810,7 +841,6 @@ LRUCache.prototype.dumpLru = function () {
810
841
  };
811
842
  /* istanbul ignore next */
812
843
 
813
-
814
844
  LRUCache.prototype.inspect = function (n, opts) {
815
845
  var str = 'LRUCache {';
816
846
  var extras = false;
@@ -869,7 +899,7 @@ LRUCache.prototype.inspect = function (n, opts) {
869
899
 
870
900
  var key = util.inspect(item.key).split('\n').join('\n ');
871
901
  var val = {
872
- value: item.value
902
+ value: item.value,
873
903
  };
874
904
 
875
905
  if (item.maxAge !== maxAge) {
@@ -1025,7 +1055,7 @@ function get(self, key, doUse) {
1025
1055
  }
1026
1056
 
1027
1057
  function isStale(self, hit) {
1028
- if (!hit || !hit.maxAge && !self[MAX_AGE]) {
1058
+ if (!hit || (!hit.maxAge && !self[MAX_AGE])) {
1029
1059
  return false;
1030
1060
  }
1031
1061
 
@@ -1043,7 +1073,7 @@ function isStale(self, hit) {
1043
1073
 
1044
1074
  function trim(self) {
1045
1075
  if (self[LENGTH] > self[MAX]) {
1046
- for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null;) {
1076
+ for (var walker = self[LRU_LIST].tail; self[LENGTH] > self[MAX] && walker !== null; ) {
1047
1077
  // We know that we're about to delete this one, and also
1048
1078
  // what the next least recently used key will be, so just
1049
1079
  // go ahead and set it now.
@@ -1063,12 +1093,11 @@ function del(self, node) {
1063
1093
  }
1064
1094
 
1065
1095
  self[LENGTH] -= hit.length;
1066
- self[CACHE]["delete"](hit.key);
1096
+ self[CACHE]['delete'](hit.key);
1067
1097
  self[LRU_LIST].removeNode(node);
1068
1098
  }
1069
1099
  } // classy, since V8 prefers predictable objects.
1070
1100
 
1071
-
1072
1101
  function Entry(key, value, length, now, maxAge) {
1073
1102
  this.key = key;
1074
1103
  this.value = value;
@@ -1085,7 +1114,7 @@ function requireWindows() {
1085
1114
  hasRequiredWindows = 1;
1086
1115
  windows = isexe;
1087
1116
  isexe.sync = sync;
1088
- var fs = require$$0__default["default"];
1117
+ var fs = require$$0__default['default'];
1089
1118
 
1090
1119
  function checkPathExt(path, options) {
1091
1120
  var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
@@ -1140,7 +1169,7 @@ function requireMode() {
1140
1169
  hasRequiredMode = 1;
1141
1170
  mode = isexe;
1142
1171
  isexe.sync = sync;
1143
- var fs = require$$0__default["default"];
1172
+ var fs = require$$0__default['default'];
1144
1173
 
1145
1174
  function isexe(path, options, cb) {
1146
1175
  fs.stat(path, function (er, stat) {
@@ -1166,7 +1195,7 @@ function requireMode() {
1166
1195
  var g = parseInt('010', 8);
1167
1196
  var o = parseInt('001', 8);
1168
1197
  var ug = u | g;
1169
- var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
1198
+ var ret = mod & o || (mod & g && gid === myGid) || (mod & u && uid === myUid) || (mod & ug && myUid === 0);
1170
1199
  return ret;
1171
1200
  }
1172
1201
 
@@ -1209,7 +1238,7 @@ function isexe$1(path, options, cb) {
1209
1238
  core(path, options || {}, function (er, is) {
1210
1239
  // ignore EACCES because that just means we aren't allowed to run it
1211
1240
  if (er) {
1212
- if (er.code === 'EACCES' || options && options.ignoreErrors) {
1241
+ if (er.code === 'EACCES' || (options && options.ignoreErrors)) {
1213
1242
  er = null;
1214
1243
  is = false;
1215
1244
  }
@@ -1224,7 +1253,7 @@ function sync$1(path, options) {
1224
1253
  try {
1225
1254
  return core.sync(path, options || {});
1226
1255
  } catch (er) {
1227
- if (options && options.ignoreErrors || er.code === 'EACCES') {
1256
+ if ((options && options.ignoreErrors) || er.code === 'EACCES') {
1228
1257
  return false;
1229
1258
  } else {
1230
1259
  throw er;
@@ -1235,7 +1264,7 @@ function sync$1(path, options) {
1235
1264
  var which_1 = which$1;
1236
1265
  which$1.sync = whichSync;
1237
1266
  var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
1238
- var path$1 = require$$0__default$1["default"];
1267
+ var path$1 = require$$0__default$1['default'];
1239
1268
  var COLON = isWindows ? ';' : ':';
1240
1269
  var isexe = isexe_1;
1241
1270
 
@@ -1262,12 +1291,11 @@ function getPathInfo(cmd, opt) {
1262
1291
  } // If it has a slash, then we don't bother searching the pathenv.
1263
1292
  // just check the file itself, and that's it.
1264
1293
 
1265
-
1266
- if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) pathEnv = [''];
1294
+ if (cmd.match(/\//) || (isWindows && cmd.match(/\\/))) pathEnv = [''];
1267
1295
  return {
1268
1296
  env: pathEnv,
1269
1297
  ext: pathExt,
1270
- extExe: pathExtExe
1298
+ extExe: pathExtExe,
1271
1299
  };
1272
1300
  }
1273
1301
 
@@ -1285,7 +1313,8 @@ function which$1(cmd, opt, cb) {
1285
1313
 
1286
1314
  (function F(i, l) {
1287
1315
  if (i === l) {
1288
- if (opt.all && found.length) return cb(null, found);else return cb(getNotFoundError(cmd));
1316
+ if (opt.all && found.length) return cb(null, found);
1317
+ else return cb(getNotFoundError(cmd));
1289
1318
  }
1290
1319
 
1291
1320
  var pathPart = pathEnv[i];
@@ -1299,15 +1328,20 @@ function which$1(cmd, opt, cb) {
1299
1328
  (function E(ii, ll) {
1300
1329
  if (ii === ll) return F(i + 1, l);
1301
1330
  var ext = pathExt[ii];
1302
- isexe(p + ext, {
1303
- pathExt: pathExtExe
1304
- }, function (er, is) {
1305
- if (!er && is) {
1306
- if (opt.all) found.push(p + ext);else return cb(null, p + ext);
1331
+ isexe(
1332
+ p + ext,
1333
+ {
1334
+ pathExt: pathExtExe,
1335
+ },
1336
+ function (er, is) {
1337
+ if (!er && is) {
1338
+ if (opt.all) found.push(p + ext);
1339
+ else return cb(null, p + ext);
1340
+ }
1341
+
1342
+ return E(ii + 1, ll);
1307
1343
  }
1308
-
1309
- return E(ii + 1, ll);
1310
- });
1344
+ );
1311
1345
  })(0, pathExt.length);
1312
1346
  })(0, pathEnv.length);
1313
1347
  }
@@ -1335,11 +1369,12 @@ function whichSync(cmd, opt) {
1335
1369
 
1336
1370
  try {
1337
1371
  is = isexe.sync(cur, {
1338
- pathExt: pathExtExe
1372
+ pathExt: pathExtExe,
1339
1373
  });
1340
1374
 
1341
1375
  if (is) {
1342
- if (opt.all) found.push(cur);else return cur;
1376
+ if (opt.all) found.push(cur);
1377
+ else return cur;
1343
1378
  }
1344
1379
  } catch (ex) {}
1345
1380
  }
@@ -1350,12 +1385,12 @@ function whichSync(cmd, opt) {
1350
1385
  throw getNotFoundError(cmd);
1351
1386
  }
1352
1387
 
1353
- var path = require$$0__default$1["default"];
1388
+ var path = require$$0__default$1['default'];
1354
1389
  var which = which_1;
1355
1390
  var LRU$1 = lruCache;
1356
1391
  var commandCache = new LRU$1({
1357
1392
  max: 50,
1358
- maxAge: 30 * 1000
1393
+ maxAge: 30 * 1000,
1359
1394
  }); // Cache just for 30sec
1360
1395
 
1361
1396
  function resolveCommand$2(command, noExtension) {
@@ -1368,9 +1403,11 @@ function resolveCommand$2(command, noExtension) {
1368
1403
  }
1369
1404
 
1370
1405
  try {
1371
- resolved = !noExtension ? which.sync(command) : which.sync(command, {
1372
- pathExt: path.delimiter + (process.env.PATHEXT || '')
1373
- });
1406
+ resolved = !noExtension
1407
+ ? which.sync(command)
1408
+ : which.sync(command, {
1409
+ pathExt: path.delimiter + (process.env.PATHEXT || ''),
1410
+ });
1374
1411
  } catch (e) {
1375
1412
  /* empty */
1376
1413
  }
@@ -1380,13 +1417,13 @@ function resolveCommand$2(command, noExtension) {
1380
1417
  }
1381
1418
 
1382
1419
  var resolveCommand_1 = resolveCommand$2;
1383
- var fs = require$$0__default["default"];
1420
+ var fs = require$$0__default['default'];
1384
1421
  var LRU = lruCache;
1385
1422
  var resolveCommand$1 = resolveCommand_1;
1386
1423
  var isWin$1 = process.platform === 'win32';
1387
1424
  var shebangCache = new LRU({
1388
1425
  max: 50,
1389
- maxAge: 30 * 1000
1426
+ maxAge: 30 * 1000,
1390
1427
  }); // Cache just for 30sec
1391
1428
 
1392
1429
  function readShebang(command) {
@@ -1399,7 +1436,6 @@ function readShebang(command) {
1399
1436
  return shebangCache.get(command);
1400
1437
  } // Read the first 150 bytes from the file
1401
1438
 
1402
-
1403
1439
  buffer = new Buffer(150);
1404
1440
 
1405
1441
  try {
@@ -1410,14 +1446,15 @@ function readShebang(command) {
1410
1446
  /* empty */
1411
1447
  } // Check if it is a shebang
1412
1448
 
1413
-
1414
- match = buffer.toString().trim().match(/#!(.+)/i);
1449
+ match = buffer
1450
+ .toString()
1451
+ .trim()
1452
+ .match(/#!(.+)/i);
1415
1453
 
1416
1454
  if (match) {
1417
1455
  shebang = match[1].replace(/\/usr\/bin\/env\s+/i, ''); // Remove /usr/bin/env
1418
1456
  } // Store the shebang in the cache
1419
1457
 
1420
-
1421
1458
  shebangCache.set(command, shebang);
1422
1459
  return shebang;
1423
1460
  }
@@ -1479,7 +1516,6 @@ function parse$1(command, args, options) {
1479
1516
  command = shebang;
1480
1517
  } // Escape command & arguments
1481
1518
 
1482
-
1483
1519
  applyQuotes = command !== 'echo'; // Do not quote arguments for the special "echo" command
1484
1520
 
1485
1521
  command = escapeCommand(command);
@@ -1498,7 +1534,7 @@ function parse$1(command, args, options) {
1498
1534
  args: args,
1499
1535
  options: options,
1500
1536
  file: file,
1501
- original: original
1537
+ original: original,
1502
1538
  };
1503
1539
  }
1504
1540
 
@@ -1556,7 +1592,6 @@ function verifyENOENTSync(status, parsed) {
1556
1592
  } // If we are in node 10, then we are using spawn-sync; if it exited
1557
1593
  // with -1 it probably means that the command does not exist
1558
1594
 
1559
-
1560
1595
  if (isNode10 && status === -1) {
1561
1596
  parsed.file = isWin ? parsed.file : resolveCommand(parsed.original);
1562
1597
 
@@ -1572,7 +1607,7 @@ enoent$1.hookChildProcess = hookChildProcess;
1572
1607
  enoent$1.verifyENOENT = verifyENOENT;
1573
1608
  enoent$1.verifyENOENTSync = verifyENOENTSync;
1574
1609
  enoent$1.notFoundError = notFoundError;
1575
- var cp = require$$0__default$2["default"];
1610
+ var cp = require$$0__default$2['default'];
1576
1611
  var parse = parse_1;
1577
1612
  var enoent = enoent$1;
1578
1613
  var cpSpawnSync = cp.spawnSync;
@@ -1595,14 +1630,13 @@ function spawnSync(command, args, options) {
1595
1630
  var result;
1596
1631
 
1597
1632
  if (!cpSpawnSync) {
1598
- try {
1599
- cpSpawnSync = require('../spawn-sync/spawn-sync'); // eslint-disable-line global-require
1600
- } catch (ex) {
1633
+ // try {
1634
+ // cpSpawnSync = require('spawn-sync'); // eslint-disable-line global-require
1635
+ // } catch (ex) {
1601
1636
  throw new Error('In order to use spawnSync on node 0.10 or older, you must ' + 'install spawn-sync:\n\n' + ' npm install spawn-sync --save');
1602
- }
1637
+ // }
1603
1638
  } // Parse the arguments
1604
1639
 
1605
-
1606
1640
  parsed = parse(command, args, options); // Spawn the child process
1607
1641
 
1608
1642
  result = cpSpawnSync(parsed.command, parsed.args, parsed.options); // Analyze if the command does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
@@ -1612,15 +1646,15 @@ function spawnSync(command, args, options) {
1612
1646
  }
1613
1647
 
1614
1648
  crossSpawn.exports = spawn;
1615
- var spawn_1 = crossSpawn.exports.spawn = spawn;
1616
- var sync = crossSpawn.exports.sync = spawnSync;
1649
+ var spawn_1 = (crossSpawn.exports.spawn = spawn);
1650
+ var sync = (crossSpawn.exports.sync = spawnSync);
1617
1651
 
1618
- var _parse = crossSpawn.exports._parse = parse;
1652
+ var _parse = (crossSpawn.exports._parse = parse);
1619
1653
 
1620
- var _enoent = crossSpawn.exports._enoent = enoent;
1654
+ var _enoent = (crossSpawn.exports._enoent = enoent);
1621
1655
 
1622
1656
  exports._enoent = _enoent;
1623
1657
  exports._parse = _parse;
1624
- exports["default"] = crossSpawn.exports;
1658
+ exports['default'] = crossSpawn.exports;
1625
1659
  exports.spawn = spawn_1;
1626
1660
  exports.sync = sync;
package/lib/index.js CHANGED
@@ -2,4 +2,3 @@ require('./polyfills');
2
2
  module.exports = require('./spawnCallback');
3
3
  module.exports.spawn = require('./spawnCallback');
4
4
  module.exports.sync = require('./spawnSyncCallback');
5
- module.exports.pathKey = require('./path-key').default;
package/lib/polyfills.js CHANGED
@@ -1,17 +1,13 @@
1
- require('core-js/actual/object/assign');
2
- require('core-js/actual/object/keys');
3
- require('core-js/actual/array/find');
4
-
5
1
  var path = require('path');
6
2
  if (typeof path.delimiter === 'undefined') path.delimiter = process.platform === 'win32' ? ';' : ':';
7
3
 
8
- if (!Buffer.from) {
9
- Buffer.from = function from(data) {
10
- // eslint-disable-next-line n/no-deprecated-api
11
- return new Buffer(data);
4
+ var cp = require('child_process');
5
+ if (!cp.spawnSync) {
6
+ var functionExec = require('function-exec-sync');
7
+
8
+ cp.spawnSync = function spawnSync(command, args, options) {
9
+ options = options || {};
10
+ var filePath = path.resolve(__dirname, 'spawnCallback.js');
11
+ return functionExec({ callbacks: true }, filePath, command, args, options);
12
12
  };
13
13
  }
14
- if (!Buffer.alloc) Buffer.alloc = Buffer.from;
15
-
16
- var cp = require('child_process');
17
- if (!cp.spawnSync) cp.spawnSync = require('./spawn-sync/spawn-sync.js');
@@ -1,4 +1,3 @@
1
- var assign = require('just-extend');
2
1
  var once = require('once');
3
2
  var nextTick = require('next-tick');
4
3
 
@@ -9,49 +8,58 @@ module.exports = function spawnCallback(command, args, options, callback) {
9
8
  if (typeof options === 'function') {
10
9
  callback = options;
11
10
  options = {};
12
- } else if (!options) options = {};
13
- else options = assign({}, options);
11
+ }
12
+ options = options || {};
14
13
  callback = once(callback);
15
14
 
16
- var result = { stdout: null, stderr: null };
17
- if (options.stdio === 'string' || options.stdout === 'string') {
18
- result.stdout = [];
19
- delete options.stdout;
20
- }
21
- if (options.stdio === 'string' || options.stderr === 'string') {
22
- result.stderr = [];
23
- delete options.stderr;
24
- }
25
15
  var cp = spawn(command, args, options);
26
-
27
- if (cp.stdout && result.stdout) {
28
- cp.stdout.on('data', function (chunk) {
29
- result.stdout.push(chunk);
30
- });
16
+ var stdout, stderr;
17
+ if (cp.stdout) {
18
+ stdout = [];
19
+ cp.stdout.on('data', stdout.push.bind(stdout));
31
20
  }
32
- if (cp.stderr && result.stderr) {
33
- cp.stderr.on('data', function (chunk) {
34
- result.stderr.push(chunk);
35
- });
21
+ if (cp.stderr) {
22
+ stderr = [];
23
+ cp.stderr.on('data', stderr.push.bind(stderr));
36
24
  }
37
-
38
25
  cp.on('error', function error(err) {
39
26
  // some versions of node emit both an error and close
40
- if (err.code !== 'OK') return callback(err);
27
+ err.code === 'OK' || callback(err);
41
28
  });
42
-
43
- cp.on('close', function close(status, signal) {
29
+ cp.on('close', function (status, signal) {
44
30
  nextTick(function closeNextTick() {
45
- result.status = status;
46
- result.signal = signal;
47
- var err = result.status ? new Error('Non-zero exit code: ' + result.status) : null;
48
- if (result.stderr && result.stderr.length) {
31
+ // format results - buffer
32
+ if (stdout) stdout = Buffer.concat(stdout);
33
+ if (stderr) stderr = Buffer.concat(stderr);
34
+
35
+ // format results - string
36
+ if ((options.encoding && options.encoding !== 'buffer')) {
37
+ stdout = stdout.toString(options.encoding);
38
+ stderr = stderr.toString(options.encoding);
39
+ }
40
+
41
+ // process errors
42
+ var err = status !== 0 ? new Error('Non-zero exit code: ' + status) : null;
43
+ if (stderr && stderr.length) {
49
44
  err = err || new Error('stderr has content');
50
- err.stderr = result.stderr.join('');
51
- } else result.stderr = null;
45
+ err.stderr = Buffer.isBuffer(stderr) ? stderr.toString('utf8') : stderr;
46
+ }
52
47
  if (err) return callback(err);
53
- if (result.stdout) result.stdout = result.stdout.join('');
54
- callback(null, result);
48
+
49
+ // non error result
50
+ callback(null, {
51
+ pid: cp.pid,
52
+ output: [null, stdout, stderr],
53
+ stdout: stdout,
54
+ stderr: stderr,
55
+ status: status,
56
+ signal: signal,
57
+ });
55
58
  });
56
59
  });
60
+
61
+ // pipe input
62
+ if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
63
+ cp.stdin.end(options.input);
64
+ }
57
65
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cross-spawn-cb",
3
- "version": "0.5.13",
3
+ "version": "0.6.0",
4
4
  "description": "Cross spawn with a completion callback",
5
5
  "keywords": [
6
6
  "cross-spawn",
@@ -24,17 +24,11 @@
24
24
  "lib"
25
25
  ],
26
26
  "dependencies": {
27
- "core-js": "^3.23.4",
28
27
  "cross-spawn": "^7.0.3",
29
- "json-buffer": "^3.0.1",
28
+ "function-exec-sync": "^0.2.1",
30
29
  "just-extend": "^6.0.1",
31
- "mkdirp": "^0.5.6",
32
30
  "next-tick": "^1.1.0",
33
- "once": "^1.4.0",
34
- "os-shim": "^0.1.3",
35
- "short-hash": "^1.0.0",
36
- "temp-suffix": "^0.1.0",
37
- "thread-sleep-compat": "^0.0.1"
31
+ "once": "^1.4.0"
38
32
  },
39
33
  "devDependencies": {
40
34
  "@babel/preset-env": "^7.18.6",
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- });
6
- var pathKey$1 = {
7
- exports: {}
8
- };
9
-
10
- var pathKey = function pathKey() {
11
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
- var environment = options.env || process.env;
13
- var platform = options.platform || process.platform;
14
-
15
- if (platform !== 'win32') {
16
- return 'PATH';
17
- }
18
-
19
- return Object.keys(environment).reverse().find(function (key) {
20
- return key.toUpperCase() === 'PATH';
21
- }) || 'Path';
22
- };
23
-
24
- pathKey$1.exports = pathKey; // TODO: Remove this for the next major release
25
-
26
- pathKey$1.exports["default"] = pathKey;
27
- exports["default"] = pathKey$1.exports;
@@ -1,9 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,19 +0,0 @@
1
- Copyright (c) 2014 Forbes Lindesay
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
@@ -1 +0,0 @@
1
- Code based on https://github.com/ForbesLindesay/spawn-sync but adapted to use cross-spawn
@@ -1,43 +0,0 @@
1
- 'use strict';
2
- /* eslint-disable */
3
-
4
- var path = require('path');
5
- var fs = require('fs');
6
- var tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
7
- var cp = require('child_process');
8
- var JSON = require('json-buffer');
9
- var sleep = require('thread-sleep-compat');
10
- var mkdirp = require('mkdirp')
11
- var suffix = require('temp-suffix')
12
- var shortHash = require('short-hash');
13
-
14
- function unlinkSafe(filename) {
15
- try {
16
- fs.unlinkSync(filename);
17
- } catch (e) {}
18
- }
19
-
20
- module.exports = function spawnSyncFallback(/*cmd, commandArgs, options*/) {
21
- var args = Array.prototype.slice.call(arguments, 0);
22
-
23
- // location to store arguments
24
- var temp = path.join(tmpdir(), 'spawn-sync', shortHash(process.cwd()));
25
- var input = path.join(temp , suffix("input"));
26
- var output = path.join(temp, suffix("output"));
27
-
28
- // store data to a file
29
- mkdirp.sync(path.dirname(input));
30
- fs.writeFileSync(input, JSON.stringify(args));
31
- unlinkSafe(output);
32
-
33
- var worker = path.normalize(__dirname + '/worker.js');
34
- cp.exec('"' + process.execPath + '" "' + worker + '" "' + input + '" "' + output + '"');
35
- while (!fs.existsSync(output)) {
36
- // busy wait
37
- sleep(200);
38
- }
39
- var res = JSON.parse(fs.readFileSync(output, 'utf8'));
40
- unlinkSafe(input);
41
- unlinkSafe(output);
42
- return res;
43
- }
@@ -1,70 +0,0 @@
1
- 'use strict';
2
- /* eslint-disable */
3
-
4
- require('../polyfills');
5
-
6
- var spawn = require('../cross-spawn-3.0.1').spawn;
7
- var fs = require('fs');
8
- var JSON = require('json-buffer');
9
-
10
- var input = process.argv[2];
11
- var output = process.argv[3];
12
-
13
- function writeOutput(result) {
14
- fs.writeFile(output+'.tmp', JSON.stringify(result), function() {
15
- fs.rename(output+'.tmp', output, function() {
16
- process.exit(0)
17
- })
18
- });
19
- }
20
-
21
- fs.readFile(input, 'utf8', function(err, contents) {
22
- if (err) return output({ error: err.message });
23
- var args = JSON.parse(contents);
24
-
25
- var child = spawn.apply(null, args);
26
- var options = args[2] && typeof args[2] === 'object' ? args[2] : args[1] && typeof args[1] === 'object' && !Array.isArray(args[1]) ? args[1] : {};
27
-
28
- var stdout, stderr;
29
- if (child.stdout) {
30
- stdout = [];
31
- child.stdout.on('data', function(chunk) {
32
- stdout.push(chunk);
33
- })
34
- }
35
- if (child.stderr) {
36
- stderr = [];
37
- child.stderr.on('data', function(chunk) {
38
- stderr.push(chunk);
39
- })
40
- }
41
- child.on('error', function (err) {
42
- writeOutput({ pid: child.pid, error: err.message });
43
- });
44
- child.on('close', function (status, signal) {
45
- if (stdout) stdout = Buffer.concat(stdout)
46
- if (stderr) stderr = Buffer.concat(stderr)
47
-
48
- if (options.encoding && options.encoding !== 'buffer') {
49
- stdout = stdout.toString(options.encoding);
50
- stderr = stderr.toString(options.encoding);
51
- }
52
- writeOutput({
53
- pid: child.pid,
54
- output: [null, stdout, stderr],
55
- stdout: stdout,
56
- stderr: stderr,
57
- status: status,
58
- signal: signal,
59
- });
60
- });
61
-
62
- if (options.timeout && typeof options.timeout === 'number') {
63
- setTimeout(function () {
64
- child.kill(options.killSignal || 'SIGTERM');
65
- }, options.timeout);
66
- }
67
- if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
68
- child.stdin.end(options.input);
69
- }
70
- })