cross-spawn-cb 1.5.3 → 1.5.5

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.
@@ -0,0 +1,676 @@
1
+ 'use strict';
2
+
3
+ var require$$0$2 = require('child_process');
4
+ var require$$0$1 = require('path');
5
+ var require$$0 = require('fs');
6
+
7
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
+ function getDefaultExportFromCjs(x) {
9
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
+ }
11
+
12
+ var nodeCrossSpawn = {
13
+ exports: {}
14
+ };
15
+
16
+ var windows;
17
+ var hasRequiredWindows;
18
+ function requireWindows() {
19
+ if (hasRequiredWindows) return windows;
20
+ hasRequiredWindows = 1;
21
+ windows = isexe;
22
+ isexe.sync = sync;
23
+ var fs = require$$0;
24
+ function checkPathExt(path, options) {
25
+ var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
26
+ if (!pathext) {
27
+ return true;
28
+ }
29
+ pathext = pathext.split(';');
30
+ if (pathext.indexOf('') !== -1) {
31
+ return true;
32
+ }
33
+ for(var i = 0; i < pathext.length; i++){
34
+ var p = pathext[i].toLowerCase();
35
+ if (p && path.substr(-p.length).toLowerCase() === p) {
36
+ return true;
37
+ }
38
+ }
39
+ return false;
40
+ }
41
+ function checkStat(stat, path, options) {
42
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
43
+ return false;
44
+ }
45
+ return checkPathExt(path, options);
46
+ }
47
+ function isexe(path, options, cb) {
48
+ fs.stat(path, function(er, stat) {
49
+ cb(er, er ? false : checkStat(stat, path, options));
50
+ });
51
+ }
52
+ function sync(path, options) {
53
+ return checkStat(fs.statSync(path), path, options);
54
+ }
55
+ return windows;
56
+ }
57
+
58
+ var mode;
59
+ var hasRequiredMode;
60
+ function requireMode() {
61
+ if (hasRequiredMode) return mode;
62
+ hasRequiredMode = 1;
63
+ mode = isexe;
64
+ isexe.sync = sync;
65
+ var fs = require$$0;
66
+ function isexe(path, options, cb) {
67
+ fs.stat(path, function(er, stat) {
68
+ cb(er, er ? false : checkStat(stat, options));
69
+ });
70
+ }
71
+ function sync(path, options) {
72
+ return checkStat(fs.statSync(path), options);
73
+ }
74
+ function checkStat(stat, options) {
75
+ return stat.isFile() && checkMode(stat, options);
76
+ }
77
+ function checkMode(stat, options) {
78
+ var mod = stat.mode;
79
+ var uid = stat.uid;
80
+ var gid = stat.gid;
81
+ var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
82
+ var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
83
+ var u = parseInt('100', 8);
84
+ var g = parseInt('010', 8);
85
+ var o = parseInt('001', 8);
86
+ var ug = u | g;
87
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
88
+ return ret;
89
+ }
90
+ return mode;
91
+ }
92
+
93
+ var isexe_1;
94
+ var hasRequiredIsexe;
95
+ function requireIsexe() {
96
+ if (hasRequiredIsexe) return isexe_1;
97
+ hasRequiredIsexe = 1;
98
+ var core;
99
+ if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
100
+ core = requireWindows();
101
+ } else {
102
+ core = requireMode();
103
+ }
104
+ isexe_1 = isexe;
105
+ isexe.sync = sync;
106
+ function isexe(path, options, cb) {
107
+ if (typeof options === 'function') {
108
+ cb = options;
109
+ options = {};
110
+ }
111
+ if (!cb) {
112
+ if (typeof Promise !== 'function') {
113
+ throw new TypeError('callback not provided');
114
+ }
115
+ return new Promise(function(resolve, reject) {
116
+ isexe(path, options || {}, function(er, is) {
117
+ if (er) {
118
+ reject(er);
119
+ } else {
120
+ resolve(is);
121
+ }
122
+ });
123
+ });
124
+ }
125
+ core(path, options || {}, function(er, is) {
126
+ // ignore EACCES because that just means we aren't allowed to run it
127
+ if (er) {
128
+ if (er.code === 'EACCES' || options && options.ignoreErrors) {
129
+ er = null;
130
+ is = false;
131
+ }
132
+ }
133
+ cb(er, is);
134
+ });
135
+ }
136
+ function sync(path, options) {
137
+ // my kingdom for a filtered catch
138
+ try {
139
+ return core.sync(path, options || {});
140
+ } catch (er) {
141
+ if (options && options.ignoreErrors || er.code === 'EACCES') {
142
+ return false;
143
+ } else {
144
+ throw er;
145
+ }
146
+ }
147
+ }
148
+ return isexe_1;
149
+ }
150
+
151
+ function _array_like_to_array$1(arr, len) {
152
+ if (len == null || len > arr.length) len = arr.length;
153
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
154
+ return arr2;
155
+ }
156
+ function _array_without_holes(arr) {
157
+ if (Array.isArray(arr)) return _array_like_to_array$1(arr);
158
+ }
159
+ function _iterable_to_array(iter) {
160
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
161
+ }
162
+ function _non_iterable_spread() {
163
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
164
+ }
165
+ function _to_consumable_array(arr) {
166
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
167
+ }
168
+ function _unsupported_iterable_to_array$1(o, minLen) {
169
+ if (!o) return;
170
+ if (typeof o === "string") return _array_like_to_array$1(o, minLen);
171
+ var n = Object.prototype.toString.call(o).slice(8, -1);
172
+ if (n === "Object" && o.constructor) n = o.constructor.name;
173
+ if (n === "Map" || n === "Set") return Array.from(n);
174
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
175
+ }
176
+ var which_1;
177
+ var hasRequiredWhich;
178
+ function requireWhich() {
179
+ if (hasRequiredWhich) return which_1;
180
+ hasRequiredWhich = 1;
181
+ var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
182
+ var path = require$$0$1;
183
+ var COLON = isWindows ? ';' : ':';
184
+ var isexe = requireIsexe();
185
+ var getNotFoundError = function(cmd) {
186
+ return Object.assign(new Error("not found: ".concat(cmd)), {
187
+ code: 'ENOENT'
188
+ });
189
+ };
190
+ var getPathInfo = function(cmd, opt) {
191
+ var colon = opt.colon || COLON;
192
+ // If it has a slash, then we don't bother searching the pathenv.
193
+ // just check the file itself, and that's it.
194
+ var pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [
195
+ ''
196
+ ] : // windows always checks the cwd first
197
+ _to_consumable_array(isWindows ? [
198
+ process.cwd()
199
+ ] : []).concat(_to_consumable_array((opt.path || process.env.PATH || /* istanbul ignore next: very unusual */ '').split(colon)));
200
+ var pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' : '';
201
+ var pathExt = isWindows ? pathExtExe.split(colon) : [
202
+ ''
203
+ ];
204
+ if (isWindows) {
205
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('');
206
+ }
207
+ return {
208
+ pathEnv: pathEnv,
209
+ pathExt: pathExt,
210
+ pathExtExe: pathExtExe
211
+ };
212
+ };
213
+ var which = function(cmd, opt, cb) {
214
+ if (typeof opt === 'function') {
215
+ cb = opt;
216
+ opt = {};
217
+ }
218
+ if (!opt) opt = {};
219
+ var _getPathInfo = getPathInfo(cmd, opt), pathEnv = _getPathInfo.pathEnv, pathExt = _getPathInfo.pathExt, pathExtExe = _getPathInfo.pathExtExe;
220
+ var found = [];
221
+ var step = function(i) {
222
+ return new Promise(function(resolve, reject) {
223
+ if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
224
+ var ppRaw = pathEnv[i];
225
+ var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
226
+ var pCmd = path.join(pathPart, cmd);
227
+ var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
228
+ resolve(subStep(p, i, 0));
229
+ });
230
+ };
231
+ var subStep = function(p, i, ii) {
232
+ return new Promise(function(resolve, reject) {
233
+ if (ii === pathExt.length) return resolve(step(i + 1));
234
+ var ext = pathExt[ii];
235
+ isexe(p + ext, {
236
+ pathExt: pathExtExe
237
+ }, function(er, is) {
238
+ if (!er && is) {
239
+ if (opt.all) found.push(p + ext);
240
+ else return resolve(p + ext);
241
+ }
242
+ return resolve(subStep(p, i, ii + 1));
243
+ });
244
+ });
245
+ };
246
+ return cb ? step(0).then(function(res) {
247
+ return cb(null, res);
248
+ }, cb) : step(0);
249
+ };
250
+ var whichSync = function(cmd, opt) {
251
+ opt = opt || {};
252
+ var _getPathInfo = getPathInfo(cmd, opt), pathEnv = _getPathInfo.pathEnv, pathExt = _getPathInfo.pathExt, pathExtExe = _getPathInfo.pathExtExe;
253
+ var found = [];
254
+ for(var i = 0; i < pathEnv.length; i++){
255
+ var ppRaw = pathEnv[i];
256
+ var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
257
+ var pCmd = path.join(pathPart, cmd);
258
+ var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
259
+ for(var j = 0; j < pathExt.length; j++){
260
+ var cur = p + pathExt[j];
261
+ try {
262
+ var is = isexe.sync(cur, {
263
+ pathExt: pathExtExe
264
+ });
265
+ if (is) {
266
+ if (opt.all) found.push(cur);
267
+ else return cur;
268
+ }
269
+ } catch (ex) {}
270
+ }
271
+ }
272
+ if (opt.all && found.length) return found;
273
+ if (opt.nothrow) return null;
274
+ throw getNotFoundError(cmd);
275
+ };
276
+ which_1 = which;
277
+ which.sync = whichSync;
278
+ return which_1;
279
+ }
280
+
281
+ var pathKey = {
282
+ exports: {}
283
+ };
284
+
285
+ var hasRequiredPathKey;
286
+ function requirePathKey() {
287
+ if (hasRequiredPathKey) return pathKey.exports;
288
+ hasRequiredPathKey = 1;
289
+ var pathKey$1 = function() {
290
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
291
+ var environment = options.env || process.env;
292
+ var platform = options.platform || process.platform;
293
+ if (platform !== 'win32') {
294
+ return 'PATH';
295
+ }
296
+ return Object.keys(environment).reverse().find(function(key) {
297
+ return key.toUpperCase() === 'PATH';
298
+ }) || 'Path';
299
+ };
300
+ pathKey.exports = pathKey$1;
301
+ // TODO: Remove this for the next major release
302
+ pathKey.exports.default = pathKey$1;
303
+ return pathKey.exports;
304
+ }
305
+
306
+ var resolveCommand_1;
307
+ var hasRequiredResolveCommand;
308
+ function requireResolveCommand() {
309
+ if (hasRequiredResolveCommand) return resolveCommand_1;
310
+ hasRequiredResolveCommand = 1;
311
+ var path = require$$0$1;
312
+ var which = requireWhich();
313
+ var getPathKey = requirePathKey();
314
+ function resolveCommandAttempt(parsed, withoutPathExt) {
315
+ var env = parsed.options.env || process.env;
316
+ var cwd = process.cwd();
317
+ var hasCustomCwd = parsed.options.cwd != null;
318
+ // Worker threads do not have process.chdir()
319
+ var shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
320
+ // If a custom `cwd` was specified, we need to change the process cwd
321
+ // because `which` will do stat calls but does not support a custom cwd
322
+ if (shouldSwitchCwd) {
323
+ try {
324
+ process.chdir(parsed.options.cwd);
325
+ } catch (err) {
326
+ /* Empty */ }
327
+ }
328
+ var resolved;
329
+ try {
330
+ resolved = which.sync(parsed.command, {
331
+ path: env[getPathKey({
332
+ env: env
333
+ })],
334
+ pathExt: withoutPathExt ? path.delimiter : undefined
335
+ });
336
+ } catch (e) {
337
+ /* Empty */ } finally{
338
+ if (shouldSwitchCwd) {
339
+ process.chdir(cwd);
340
+ }
341
+ }
342
+ // If we successfully resolved, ensure that an absolute path is returned
343
+ // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
344
+ if (resolved) {
345
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
346
+ }
347
+ return resolved;
348
+ }
349
+ function resolveCommand(parsed) {
350
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
351
+ }
352
+ resolveCommand_1 = resolveCommand;
353
+ return resolveCommand_1;
354
+ }
355
+
356
+ var _escape = {};
357
+
358
+ var hasRequired_escape;
359
+ function require_escape() {
360
+ if (hasRequired_escape) return _escape;
361
+ hasRequired_escape = 1;
362
+ // See http://www.robvanderwoude.com/escapechars.php
363
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
364
+ function escapeCommand(arg) {
365
+ // Escape meta chars
366
+ arg = arg.replace(metaCharsRegExp, '^$1');
367
+ return arg;
368
+ }
369
+ function escapeArgument(arg, doubleEscapeMetaChars) {
370
+ // Convert to string
371
+ arg = "".concat(arg);
372
+ // Algorithm below is based on https://qntm.org/cmd
373
+ // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
374
+ // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
375
+ // Sequence of backslashes followed by a double quote:
376
+ // double up all the backslashes and escape the double quote
377
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
378
+ // Sequence of backslashes followed by the end of the string
379
+ // (which will become a double quote later):
380
+ // double up all the backslashes
381
+ arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
382
+ // All other backslashes occur literally
383
+ // Quote the whole thing:
384
+ arg = '"'.concat(arg, '"');
385
+ // Escape meta chars
386
+ arg = arg.replace(metaCharsRegExp, '^$1');
387
+ // Double escape meta chars if necessary
388
+ if (doubleEscapeMetaChars) {
389
+ arg = arg.replace(metaCharsRegExp, '^$1');
390
+ }
391
+ return arg;
392
+ }
393
+ _escape.command = escapeCommand;
394
+ _escape.argument = escapeArgument;
395
+ return _escape;
396
+ }
397
+
398
+ var shebangRegex;
399
+ var hasRequiredShebangRegex;
400
+ function requireShebangRegex() {
401
+ if (hasRequiredShebangRegex) return shebangRegex;
402
+ hasRequiredShebangRegex = 1;
403
+ shebangRegex = /^#!(.*)/;
404
+ return shebangRegex;
405
+ }
406
+
407
+ function _array_like_to_array(arr, len) {
408
+ if (len == null || len > arr.length) len = arr.length;
409
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
410
+ return arr2;
411
+ }
412
+ function _array_with_holes(arr) {
413
+ if (Array.isArray(arr)) return arr;
414
+ }
415
+ function _iterable_to_array_limit(arr, i) {
416
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
417
+ if (_i == null) return;
418
+ var _arr = [];
419
+ var _n = true;
420
+ var _d = false;
421
+ var _s, _e;
422
+ try {
423
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
424
+ _arr.push(_s.value);
425
+ if (i && _arr.length === i) break;
426
+ }
427
+ } catch (err) {
428
+ _d = true;
429
+ _e = err;
430
+ } finally{
431
+ try {
432
+ if (!_n && _i["return"] != null) _i["return"]();
433
+ } finally{
434
+ if (_d) throw _e;
435
+ }
436
+ }
437
+ return _arr;
438
+ }
439
+ function _non_iterable_rest() {
440
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
441
+ }
442
+ function _sliced_to_array(arr, i) {
443
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
444
+ }
445
+ function _unsupported_iterable_to_array(o, minLen) {
446
+ if (!o) return;
447
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
448
+ var n = Object.prototype.toString.call(o).slice(8, -1);
449
+ if (n === "Object" && o.constructor) n = o.constructor.name;
450
+ if (n === "Map" || n === "Set") return Array.from(n);
451
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
452
+ }
453
+ var shebangCommand;
454
+ var hasRequiredShebangCommand;
455
+ function requireShebangCommand() {
456
+ if (hasRequiredShebangCommand) return shebangCommand;
457
+ hasRequiredShebangCommand = 1;
458
+ var shebangRegex = requireShebangRegex();
459
+ shebangCommand = function() {
460
+ var string = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
461
+ var match = string.match(shebangRegex);
462
+ if (!match) {
463
+ return null;
464
+ }
465
+ var _match__replace_split = _sliced_to_array(match[0].replace(/#! ?/, '').split(' '), 2), path = _match__replace_split[0], argument = _match__replace_split[1];
466
+ var binary = path.split('/').pop();
467
+ if (binary === 'env') {
468
+ return argument;
469
+ }
470
+ return argument ? "".concat(binary, " ").concat(argument) : binary;
471
+ };
472
+ return shebangCommand;
473
+ }
474
+
475
+ var readShebang_1;
476
+ var hasRequiredReadShebang;
477
+ function requireReadShebang() {
478
+ if (hasRequiredReadShebang) return readShebang_1;
479
+ hasRequiredReadShebang = 1;
480
+ var fs = require$$0;
481
+ var shebangCommand = requireShebangCommand();
482
+ function readShebang(command) {
483
+ // Read the first 150 bytes from the file
484
+ var size = 150;
485
+ var buffer = Buffer.alloc(size);
486
+ var fd;
487
+ try {
488
+ fd = fs.openSync(command, 'r');
489
+ fs.readSync(fd, buffer, 0, size, 0);
490
+ fs.closeSync(fd);
491
+ } catch (e) {}
492
+ // Attempt to extract shebang (null is returned if not a shebang)
493
+ return shebangCommand(buffer.toString());
494
+ }
495
+ readShebang_1 = readShebang;
496
+ return readShebang_1;
497
+ }
498
+
499
+ var parse_1;
500
+ var hasRequiredParse;
501
+ function requireParse() {
502
+ if (hasRequiredParse) return parse_1;
503
+ hasRequiredParse = 1;
504
+ var path = require$$0$1;
505
+ var resolveCommand = requireResolveCommand();
506
+ var escape = require_escape();
507
+ var readShebang = requireReadShebang();
508
+ var isWin = process.platform === 'win32';
509
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
510
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
511
+ function detectShebang(parsed) {
512
+ parsed.file = resolveCommand(parsed);
513
+ var shebang = parsed.file && readShebang(parsed.file);
514
+ if (shebang) {
515
+ parsed.args.unshift(parsed.file);
516
+ parsed.command = shebang;
517
+ return resolveCommand(parsed);
518
+ }
519
+ return parsed.file;
520
+ }
521
+ function parseNonShell(parsed) {
522
+ if (!isWin) {
523
+ return parsed;
524
+ }
525
+ // Detect & add support for shebangs
526
+ var commandFile = detectShebang(parsed);
527
+ // We don't need a shell if the command filename is an executable
528
+ var needsShell = !isExecutableRegExp.test(commandFile);
529
+ // If a shell is required, use cmd.exe and take care of escaping everything correctly
530
+ // Note that `forceShell` is an hidden option used only in tests
531
+ if (parsed.options.forceShell || needsShell) {
532
+ // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
533
+ // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
534
+ // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
535
+ // we need to double escape them
536
+ var needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
537
+ // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
538
+ // This is necessary otherwise it will always fail with ENOENT in those cases
539
+ parsed.command = path.normalize(parsed.command);
540
+ // Escape command & arguments
541
+ parsed.command = escape.command(parsed.command);
542
+ parsed.args = parsed.args.map(function(arg) {
543
+ return escape.argument(arg, needsDoubleEscapeMetaChars);
544
+ });
545
+ var shellCommand = [
546
+ parsed.command
547
+ ].concat(parsed.args).join(' ');
548
+ parsed.args = [
549
+ '/d',
550
+ '/s',
551
+ '/c',
552
+ '"'.concat(shellCommand, '"')
553
+ ];
554
+ parsed.command = process.env.comspec || 'cmd.exe';
555
+ parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
556
+ }
557
+ return parsed;
558
+ }
559
+ function parse(command, args, options) {
560
+ // Normalize arguments, similar to nodejs
561
+ if (args && !Array.isArray(args)) {
562
+ options = args;
563
+ args = null;
564
+ }
565
+ args = args ? args.slice(0) : []; // Clone array to avoid changing the original
566
+ options = Object.assign({}, options); // Clone object to avoid changing the original
567
+ // Build our parsed object
568
+ var parsed = {
569
+ command: command,
570
+ args: args,
571
+ options: options,
572
+ file: undefined,
573
+ original: {
574
+ command: command,
575
+ args: args
576
+ }
577
+ };
578
+ // Delegate further parsing to shell or non-shell
579
+ return options.shell ? parsed : parseNonShell(parsed);
580
+ }
581
+ parse_1 = parse;
582
+ return parse_1;
583
+ }
584
+
585
+ var enoent;
586
+ var hasRequiredEnoent;
587
+ function requireEnoent() {
588
+ if (hasRequiredEnoent) return enoent;
589
+ hasRequiredEnoent = 1;
590
+ var isWin = process.platform === 'win32';
591
+ function notFoundError(original, syscall) {
592
+ return Object.assign(new Error("".concat(syscall, " ").concat(original.command, " ENOENT")), {
593
+ code: 'ENOENT',
594
+ errno: 'ENOENT',
595
+ syscall: "".concat(syscall, " ").concat(original.command),
596
+ path: original.command,
597
+ spawnargs: original.args
598
+ });
599
+ }
600
+ function hookChildProcess(cp, parsed) {
601
+ if (!isWin) {
602
+ return;
603
+ }
604
+ var originalEmit = cp.emit;
605
+ cp.emit = function(name, arg1) {
606
+ // If emitting "exit" event and exit code is 1, we need to check if
607
+ // the command exists and emit an "error" instead
608
+ // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
609
+ if (name === 'exit') {
610
+ var err = verifyENOENT(arg1, parsed);
611
+ if (err) {
612
+ return originalEmit.call(cp, 'error', err);
613
+ }
614
+ }
615
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
616
+ };
617
+ }
618
+ function verifyENOENT(status, parsed) {
619
+ if (isWin && status === 1 && !parsed.file) {
620
+ return notFoundError(parsed.original, 'spawn');
621
+ }
622
+ return null;
623
+ }
624
+ function verifyENOENTSync(status, parsed) {
625
+ if (isWin && status === 1 && !parsed.file) {
626
+ return notFoundError(parsed.original, 'spawnSync');
627
+ }
628
+ return null;
629
+ }
630
+ enoent = {
631
+ hookChildProcess: hookChildProcess,
632
+ verifyENOENT: verifyENOENT,
633
+ verifyENOENTSync: verifyENOENTSync,
634
+ notFoundError: notFoundError
635
+ };
636
+ return enoent;
637
+ }
638
+
639
+ var hasRequiredNodeCrossSpawn;
640
+ function requireNodeCrossSpawn() {
641
+ if (hasRequiredNodeCrossSpawn) return nodeCrossSpawn.exports;
642
+ hasRequiredNodeCrossSpawn = 1;
643
+ var cp = require$$0$2;
644
+ var parse = requireParse();
645
+ var enoent = requireEnoent();
646
+ function spawn(command, args, options) {
647
+ // Parse the arguments
648
+ var parsed = parse(command, args, options);
649
+ // Spawn the child process
650
+ var spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
651
+ // Hook into child process "exit" event to emit an error if the command
652
+ // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
653
+ enoent.hookChildProcess(spawned, parsed);
654
+ return spawned;
655
+ }
656
+ function spawnSync(command, args, options) {
657
+ // Parse the arguments
658
+ var parsed = parse(command, args, options);
659
+ // Spawn the child process
660
+ var result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
661
+ // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
662
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
663
+ return result;
664
+ }
665
+ nodeCrossSpawn.exports = spawn;
666
+ nodeCrossSpawn.exports.spawn = spawn;
667
+ nodeCrossSpawn.exports.sync = spawnSync;
668
+ nodeCrossSpawn.exports._parse = parse;
669
+ nodeCrossSpawn.exports._enoent = enoent;
670
+ return nodeCrossSpawn.exports;
671
+ }
672
+
673
+ var nodeCrossSpawnExports = requireNodeCrossSpawn();
674
+ var index = /*@__PURE__*/ getDefaultExportFromCjs(nodeCrossSpawnExports);
675
+
676
+ module.exports = index;
package/dist/cjs/spawn.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  var major = +process.versions.node.split('.')[0];
3
- module.exports = major <= 7 ? require('../../assets/cross-spawn-6.0.5.js') : require('cross-spawn');
3
+ module.exports = major <= 7 ? require('./spawnCompat/index.js') : require('cross-spawn');
4
4
  /* 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; }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/@compat/cross-spawn-cb/src/spawn.cjs"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\n\nmodule.exports = major <= 7 ? require('../../assets/cross-spawn-6.0.5.js') : require('cross-spawn');\n"],"names":["major","process","versions","node","split","module","exports","require"],"mappings":";AAAA,IAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElDC,OAAOC,OAAO,GAAGN,SAAS,IAAIO,QAAQ,uCAAuCA,QAAQ"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/@compat/cross-spawn-cb/src/spawn.cjs"],"sourcesContent":["const major = +process.versions.node.split('.')[0];\n\nmodule.exports = major <= 7 ? require('./spawnCompat/index.cjs') : require('cross-spawn');\n"],"names":["major","process","versions","node","split","module","exports","require"],"mappings":";AAAA,IAAMA,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElDC,OAAOC,OAAO,GAAGN,SAAS,IAAIO,QAAQ,6BAA6BA,QAAQ"}