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