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