cross-spawn-cb 1.5.4 → 1.5.6

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