cross-spawn-cb 1.5.2 → 1.5.4

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.
@@ -1,100 +1,128 @@
1
1
  'use strict';
2
2
 
3
- var require$$0$1 = require('path');
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
+
4
9
  var require$$0$2 = require('child_process');
10
+
11
+ var require$$0$1 = require('path');
12
+
5
13
  var require$$0 = require('fs');
6
14
 
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;
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
+ };
10
21
  }
11
22
 
12
- var src$1 = {
13
- exports: {}
14
- };
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);
15
28
 
16
- var crossSpawn6_0_5 = {
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 = {
17
33
  exports: {}
18
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
+ */
19
40
 
20
- var src;
21
- var hasRequiredSrc$1;
22
- function requireSrc$1() {
23
- if (hasRequiredSrc$1) return src;
24
- hasRequiredSrc$1 = 1;
25
- /**
26
- * Tries to execute a function and discards any error that occurs.
27
- * @param {Function} fn - Function that might or might not throw an error.
28
- * @returns {?*} Return-value of the function when no error occurred.
29
- */ src = function src(fn) {
30
- try {
31
- return fn();
32
- } catch (e) {}
33
- };
34
- return src;
35
- }
41
+ var src = function src(fn) {
42
+ try {
43
+ return fn();
44
+ } catch (e) { }
45
+ };
36
46
 
37
47
  var windows;
38
48
  var hasRequiredWindows;
49
+
39
50
  function requireWindows() {
40
51
  if (hasRequiredWindows) return windows;
41
52
  hasRequiredWindows = 1;
42
53
  windows = isexe;
43
54
  isexe.sync = sync;
44
- var fs = require$$0;
55
+ var fs = require$$0__default["default"];
56
+
45
57
  function checkPathExt(path, options) {
46
58
  var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
59
+
47
60
  if (!pathext) {
48
61
  return true;
49
62
  }
63
+
50
64
  pathext = pathext.split(';');
65
+
51
66
  if (pathext.indexOf('') !== -1) {
52
67
  return true;
53
68
  }
54
- for(var i = 0; i < pathext.length; i++){
69
+
70
+ for (var i = 0; i < pathext.length; i++) {
55
71
  var p = pathext[i].toLowerCase();
72
+
56
73
  if (p && path.substr(-p.length).toLowerCase() === p) {
57
74
  return true;
58
75
  }
59
76
  }
77
+
60
78
  return false;
61
79
  }
80
+
62
81
  function checkStat(stat, path, options) {
63
82
  if (!stat.isSymbolicLink() && !stat.isFile()) {
64
83
  return false;
65
84
  }
85
+
66
86
  return checkPathExt(path, options);
67
87
  }
88
+
68
89
  function isexe(path, options, cb) {
69
- fs.stat(path, function(er, stat) {
90
+ fs.stat(path, function (er, stat) {
70
91
  cb(er, er ? false : checkStat(stat, path, options));
71
92
  });
72
93
  }
94
+
73
95
  function sync(path, options) {
74
96
  return checkStat(fs.statSync(path), path, options);
75
97
  }
98
+
76
99
  return windows;
77
100
  }
78
101
 
79
102
  var mode;
80
103
  var hasRequiredMode;
104
+
81
105
  function requireMode() {
82
106
  if (hasRequiredMode) return mode;
83
107
  hasRequiredMode = 1;
84
108
  mode = isexe;
85
109
  isexe.sync = sync;
86
- var fs = require$$0;
110
+ var fs = require$$0__default["default"];
111
+
87
112
  function isexe(path, options, cb) {
88
- fs.stat(path, function(er, stat) {
113
+ fs.stat(path, function (er, stat) {
89
114
  cb(er, er ? false : checkStat(stat, options));
90
115
  });
91
116
  }
117
+
92
118
  function sync(path, options) {
93
119
  return checkStat(fs.statSync(path), options);
94
120
  }
121
+
95
122
  function checkStat(stat, options) {
96
123
  return stat.isFile() && checkMode(stat, options);
97
124
  }
125
+
98
126
  function checkMode(stat, options) {
99
127
  var mod = stat.mode;
100
128
  var uid = stat.uid;
@@ -108,1859 +136,542 @@ function requireMode() {
108
136
  var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
109
137
  return ret;
110
138
  }
139
+
111
140
  return mode;
112
141
  }
113
142
 
114
- var isexe_1;
115
- var hasRequiredIsexe;
116
- function requireIsexe() {
117
- if (hasRequiredIsexe) return isexe_1;
118
- hasRequiredIsexe = 1;
119
- var core;
120
- if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
121
- core = requireWindows();
122
- } else {
123
- core = requireMode();
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 = {};
124
158
  }
125
- isexe_1 = isexe;
126
- isexe.sync = sync;
127
- function isexe(path, options, cb) {
128
- if (typeof options === 'function') {
129
- cb = options;
130
- options = {};
131
- }
132
- if (!cb) {
133
- if (typeof Promise !== 'function') {
134
- throw new TypeError('callback not provided');
135
- }
136
- return new Promise(function(resolve, reject) {
137
- isexe(path, options || {}, function(er, is) {
138
- if (er) {
139
- reject(er);
140
- } else {
141
- resolve(is);
142
- }
143
- });
144
- });
159
+
160
+ if (!cb) {
161
+ if (typeof Promise !== 'function') {
162
+ throw new TypeError('callback not provided');
145
163
  }
146
- core(path, options || {}, function(er, is) {
147
- // ignore EACCES because that just means we aren't allowed to run it
148
- if (er) {
149
- if (er.code === 'EACCES' || options && options.ignoreErrors) {
150
- er = null;
151
- is = false;
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);
152
171
  }
153
- }
154
- cb(er, is);
172
+ });
155
173
  });
156
174
  }
157
- function sync(path, options) {
158
- // my kingdom for a filtered catch
159
- try {
160
- return core.sync(path, options || {});
161
- } catch (er) {
162
- if (options && options.ignoreErrors || er.code === 'EACCES') {
163
- return false;
164
- } else {
165
- throw er;
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;
166
182
  }
167
183
  }
168
- }
169
- return isexe_1;
184
+
185
+ cb(er, is);
186
+ });
170
187
  }
171
188
 
172
- var which_1;
173
- var hasRequiredWhich;
174
- function requireWhich() {
175
- if (hasRequiredWhich) return which_1;
176
- hasRequiredWhich = 1;
177
- which_1 = which;
178
- which.sync = whichSync;
179
- var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
180
- var path = require$$0$1;
181
- var COLON = isWindows ? ';' : ':';
182
- var isexe = requireIsexe();
183
- function getNotFoundError(cmd) {
184
- var er = new Error('not found: ' + cmd);
185
- er.code = 'ENOENT';
186
- return er;
187
- }
188
- function getPathInfo(cmd, opt) {
189
- var colon = opt.colon || COLON;
190
- var pathEnv = opt.path || process.env.PATH || '';
191
- var pathExt = [
192
- ''
193
- ];
194
- pathEnv = pathEnv.split(colon);
195
- var pathExtExe = '';
196
- if (isWindows) {
197
- pathEnv.unshift(process.cwd());
198
- pathExtExe = opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM';
199
- pathExt = pathExtExe.split(colon);
200
- // Always test the cmd itself first. isexe will check to make sure
201
- // it's found in the pathExt set.
202
- if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('');
203
- }
204
- // If it has a slash, then we don't bother searching the pathenv.
205
- // just check the file itself, and that's it.
206
- if (cmd.match(/\//) || isWindows && cmd.match(/\\/)) pathEnv = [
207
- ''
208
- ];
209
- return {
210
- env: pathEnv,
211
- ext: pathExt,
212
- extExe: pathExtExe
213
- };
214
- }
215
- function which(cmd, opt, cb) {
216
- if (typeof opt === 'function') {
217
- cb = opt;
218
- opt = {};
219
- }
220
- var info = getPathInfo(cmd, opt);
221
- var pathEnv = info.env;
222
- var pathExt = info.ext;
223
- var pathExtExe = info.extExe;
224
- var found = [];
225
- (function F(i, l) {
226
- if (i === l) {
227
- if (opt.all && found.length) return cb(null, found);
228
- else return cb(getNotFoundError(cmd));
229
- }
230
- var pathPart = pathEnv[i];
231
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') pathPart = pathPart.slice(1, -1);
232
- var p = path.join(pathPart, cmd);
233
- if (!pathPart && /^\.[\\\/]/.test(cmd)) {
234
- p = cmd.slice(0, 2) + p;
235
- }
236
- (function E(ii, ll) {
237
- if (ii === ll) return F(i + 1, l);
238
- var ext = pathExt[ii];
239
- isexe(p + ext, {
240
- pathExt: pathExtExe
241
- }, function(er, is) {
242
- if (!er && is) {
243
- if (opt.all) found.push(p + ext);
244
- else return cb(null, p + ext);
245
- }
246
- return E(ii + 1, ll);
247
- });
248
- })(0, pathExt.length);
249
- })(0, pathEnv.length);
250
- }
251
- function whichSync(cmd, opt) {
252
- opt = opt || {};
253
- var info = getPathInfo(cmd, opt);
254
- var pathEnv = info.env;
255
- var pathExt = info.ext;
256
- var pathExtExe = info.extExe;
257
- var found = [];
258
- for(var i = 0, l = pathEnv.length; i < l; i++){
259
- var pathPart = pathEnv[i];
260
- if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"') pathPart = pathPart.slice(1, -1);
261
- var p = path.join(pathPart, cmd);
262
- if (!pathPart && /^\.[\\\/]/.test(cmd)) {
263
- p = cmd.slice(0, 2) + p;
264
- }
265
- for(var j = 0, ll = pathExt.length; j < ll; j++){
266
- var cur = p + pathExt[j];
267
- var is;
268
- try {
269
- is = isexe.sync(cur, {
270
- pathExt: pathExtExe
271
- });
272
- if (is) {
273
- if (opt.all) found.push(cur);
274
- else return cur;
275
- }
276
- } catch (ex) {}
277
- }
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;
278
198
  }
279
- if (opt.all && found.length) return found;
280
- if (opt.nothrow) return null;
281
- throw getNotFoundError(cmd);
282
199
  }
283
- return which_1;
284
200
  }
285
201
 
286
- var pathKey;
287
- var hasRequiredPathKey;
288
- function requirePathKey() {
289
- if (hasRequiredPathKey) return pathKey;
290
- hasRequiredPathKey = 1;
291
- pathKey = function(opts) {
292
- opts = opts || {};
293
- var env = opts.env || process.env;
294
- var platform = opts.platform || process.platform;
295
- if (platform !== 'win32') {
296
- return 'PATH';
297
- }
298
- return Object.keys(env).find(function(x) {
299
- return x.toUpperCase() === 'PATH';
300
- }) || 'Path';
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
301
238
  };
302
- return pathKey;
303
239
  }
304
240
 
305
- var resolveCommand_1;
306
- var hasRequiredResolveCommand;
307
- function requireResolveCommand() {
308
- if (hasRequiredResolveCommand) return resolveCommand_1;
309
- hasRequiredResolveCommand = 1;
310
- var path = require$$0$1;
311
- var which = requireWhich();
312
- var pathKey = requirePathKey()();
313
- function resolveCommandAttempt(parsed, withoutPathExt) {
314
- var cwd = process.cwd();
315
- var hasCustomCwd = parsed.options.cwd != null;
316
- // If a custom `cwd` was specified, we need to change the process cwd
317
- // because `which` will do stat calls but does not support a custom cwd
318
- if (hasCustomCwd) {
319
- try {
320
- process.chdir(parsed.options.cwd);
321
- } catch (err) {
322
- /* Empty */ }
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));
323
256
  }
324
- var resolved;
325
- try {
326
- resolved = which.sync(parsed.command, {
327
- path: (parsed.options.env || process.env)[pathKey],
328
- pathExt: withoutPathExt ? path.delimiter : undefined
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);
329
277
  });
330
- } catch (e) {
331
- /* Empty */ } finally{
332
- process.chdir(cwd);
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;
333
297
  }
334
- // If we successfully resolved, ensure that an absolute path is returned
335
- // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
336
- if (resolved) {
337
- resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
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) { }
338
312
  }
339
- return resolved;
340
313
  }
341
- function resolveCommand(parsed) {
342
- return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
343
- }
344
- resolveCommand_1 = resolveCommand;
345
- return resolveCommand_1;
314
+
315
+ if (opt.all && found.length) return found;
316
+ if (opt.nothrow) return null;
317
+ throw getNotFoundError(cmd);
346
318
  }
347
319
 
348
- var _escape = {};
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;
349
324
 
350
- var hasRequired_escape;
351
- function require_escape() {
352
- if (hasRequired_escape) return _escape;
353
- hasRequired_escape = 1;
354
- // See http://www.robvanderwoude.com/escapechars.php
355
- var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
356
- function escapeCommand(arg) {
357
- // Escape meta chars
358
- arg = arg.replace(metaCharsRegExp, '^$1');
359
- return arg;
325
+ if (platform !== 'win32') {
326
+ return 'PATH';
360
327
  }
361
- function escapeArgument(arg, doubleEscapeMetaChars) {
362
- // Convert to string
363
- arg = "".concat(arg);
364
- // Algorithm below is based on https://qntm.org/cmd
365
- // Sequence of backslashes followed by a double quote:
366
- // double up all the backslashes and escape the double quote
367
- arg = arg.replace(/(\\*)"/g, '$1$1\\"');
368
- // Sequence of backslashes followed by the end of the string
369
- // (which will become a double quote later):
370
- // double up all the backslashes
371
- arg = arg.replace(/(\\*)$/, '$1$1');
372
- // All other backslashes occur literally
373
- // Quote the whole thing:
374
- arg = '"'.concat(arg, '"');
375
- // Escape meta chars
376
- arg = arg.replace(metaCharsRegExp, '^$1');
377
- // Double escape meta chars if necessary
378
- if (doubleEscapeMetaChars) {
379
- arg = arg.replace(metaCharsRegExp, '^$1');
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 */
380
348
  }
381
- return arg;
382
349
  }
383
- _escape.command = escapeCommand;
384
- _escape.argument = escapeArgument;
385
- return _escape;
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;
386
371
  }
387
372
 
388
- var shebangRegex;
389
- var hasRequiredShebangRegex;
390
- function requireShebangRegex() {
391
- if (hasRequiredShebangRegex) return shebangRegex;
392
- hasRequiredShebangRegex = 1;
393
- shebangRegex = /^#!.*/;
394
- return shebangRegex;
373
+ function resolveCommand$1(parsed) {
374
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
395
375
  }
396
376
 
397
- var shebangCommand;
398
- var hasRequiredShebangCommand;
399
- function requireShebangCommand() {
400
- if (hasRequiredShebangCommand) return shebangCommand;
401
- hasRequiredShebangCommand = 1;
402
- var shebangRegex = requireShebangRegex();
403
- shebangCommand = function shebangCommand(str) {
404
- var match = str.match(shebangRegex);
405
- if (!match) {
406
- return null;
407
- }
408
- var arr = match[0].replace(/#! ?/, '').split(' ');
409
- var bin = arr[0].split('/').pop();
410
- var arg = arr[1];
411
- return bin === 'env' ? arg : bin + (arg ? ' ' + arg : '');
412
- };
413
- return shebangCommand;
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;
414
386
  }
415
387
 
416
- var readShebang_1;
417
- var hasRequiredReadShebang;
418
- function requireReadShebang() {
419
- if (hasRequiredReadShebang) return readShebang_1;
420
- hasRequiredReadShebang = 1;
421
- var fs = require$$0;
422
- var shebangCommand = requireShebangCommand();
423
- function readShebang(command) {
424
- // Read the first 150 bytes from the file
425
- var size = 150;
426
- var buffer;
427
- if (Buffer.alloc) {
428
- // Node.js v4.5+ / v5.10+
429
- buffer = Buffer.alloc(size);
430
- } else {
431
- // Old Node.js API
432
- buffer = new Buffer(size);
433
- buffer.fill(0); // zero-fill
434
- }
435
- var fd;
436
- try {
437
- fd = fs.openSync(command, 'r');
438
- fs.readSync(fd, buffer, 0, size, 0);
439
- fs.closeSync(fd);
440
- } catch (e) {}
441
- // Attempt to extract shebang (null is returned if not a shebang)
442
- return shebangCommand(buffer.toString());
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');
443
407
  }
444
- readShebang_1 = readShebang;
445
- return readShebang_1;
408
+
409
+ return arg;
446
410
  }
447
411
 
448
- var semver = {
449
- exports: {}
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 : '');
450
428
  };
451
429
 
452
- function _instanceof(left, right) {
453
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
454
- return !!right[Symbol.hasInstance](left);
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);
455
441
  } else {
456
- return left instanceof right;
442
+ // Old Node.js API
443
+ buffer = new Buffer(size);
444
+ buffer.fill(0); // zero-fill
457
445
  }
458
- }
459
- function _type_of(obj) {
460
- "@swc/helpers - typeof";
461
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
462
- }
463
- var hasRequiredSemver;
464
- function requireSemver() {
465
- if (hasRequiredSemver) return semver.exports;
466
- hasRequiredSemver = 1;
467
- (function(module, exports) {
468
- exports = module.exports = SemVer;
469
- var debug;
470
- /* istanbul ignore next */ if ((typeof process === "undefined" ? "undefined" : _type_of(process)) === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
471
- debug = function debug() {
472
- var args = Array.prototype.slice.call(arguments, 0);
473
- args.unshift('SEMVER');
474
- console.log.apply(console, args);
475
- };
476
- } else {
477
- debug = function debug() {};
478
- }
479
- // Note: this is the semver.org version of the spec that it implements
480
- // Not necessarily the package version of this code.
481
- exports.SEMVER_SPEC_VERSION = '2.0.0';
482
- var MAX_LENGTH = 256;
483
- var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */ 9007199254740991;
484
- // Max safe segment length for coercion.
485
- var MAX_SAFE_COMPONENT_LENGTH = 16;
486
- var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
487
- // The actual regexps go on exports.re
488
- var re = exports.re = [];
489
- var safeRe = exports.safeRe = [];
490
- var src = exports.src = [];
491
- var R = 0;
492
- var LETTERDASHNUMBER = '[a-zA-Z0-9-]';
493
- // Replace some greedy regex tokens to prevent regex dos issues. These regex are
494
- // used internally via the safeRe object since all inputs in this library get
495
- // normalized first to trim and collapse all extra whitespace. The original
496
- // regexes are exported for userland consumption and lower level usage. A
497
- // future breaking change could export the safer regex only with a note that
498
- // all input should have extra whitespace removed.
499
- var safeRegexReplacements = [
500
- [
501
- '\\s',
502
- 1
503
- ],
504
- [
505
- '\\d',
506
- MAX_LENGTH
507
- ],
508
- [
509
- LETTERDASHNUMBER,
510
- MAX_SAFE_BUILD_LENGTH
511
- ]
512
- ];
513
- function makeSafeRe(value) {
514
- for(var i = 0; i < safeRegexReplacements.length; i++){
515
- var token = safeRegexReplacements[i][0];
516
- var max = safeRegexReplacements[i][1];
517
- value = value.split(token + '*').join(token + '{0,' + max + '}').split(token + '+').join(token + '{1,' + max + '}');
518
- }
519
- return value;
520
- }
521
- // The following Regular Expressions can be used for tokenizing,
522
- // validating, and parsing SemVer version strings.
523
- // ## Numeric Identifier
524
- // A single `0`, or a non-zero digit followed by zero or more digits.
525
- var NUMERICIDENTIFIER = R++;
526
- src[NUMERICIDENTIFIER] = '0|[1-9]\\d*';
527
- var NUMERICIDENTIFIERLOOSE = R++;
528
- src[NUMERICIDENTIFIERLOOSE] = '\\d+';
529
- // ## Non-numeric Identifier
530
- // Zero or more digits, followed by a letter or hyphen, and then zero or
531
- // more letters, digits, or hyphens.
532
- var NONNUMERICIDENTIFIER = R++;
533
- src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*';
534
- // ## Main Version
535
- // Three dot-separated numeric identifiers.
536
- var MAINVERSION = R++;
537
- src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')\\.' + '(' + src[NUMERICIDENTIFIER] + ')';
538
- var MAINVERSIONLOOSE = R++;
539
- src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' + '(' + src[NUMERICIDENTIFIERLOOSE] + ')';
540
- // ## Pre-release Version Identifier
541
- // A numeric identifier, or a non-numeric identifier.
542
- var PRERELEASEIDENTIFIER = R++;
543
- src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] + '|' + src[NONNUMERICIDENTIFIER] + ')';
544
- var PRERELEASEIDENTIFIERLOOSE = R++;
545
- src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] + '|' + src[NONNUMERICIDENTIFIER] + ')';
546
- // ## Pre-release Version
547
- // Hyphen, followed by one or more dot-separated pre-release version
548
- // identifiers.
549
- var PRERELEASE = R++;
550
- src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] + '(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))';
551
- var PRERELEASELOOSE = R++;
552
- src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] + '(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))';
553
- // ## Build Metadata Identifier
554
- // Any combination of digits, letters, or hyphens.
555
- var BUILDIDENTIFIER = R++;
556
- src[BUILDIDENTIFIER] = LETTERDASHNUMBER + '+';
557
- // ## Build Metadata
558
- // Plus sign, followed by one or more period-separated build metadata
559
- // identifiers.
560
- var BUILD = R++;
561
- src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] + '(?:\\.' + src[BUILDIDENTIFIER] + ')*))';
562
- // ## Full Version String
563
- // A main version, followed optionally by a pre-release version and
564
- // build metadata.
565
- // Note that the only major, minor, patch, and pre-release sections of
566
- // the version string are capturing groups. The build metadata is not a
567
- // capturing group, because it should not ever be used in version
568
- // comparison.
569
- var FULL = R++;
570
- var FULLPLAIN = 'v?' + src[MAINVERSION] + src[PRERELEASE] + '?' + src[BUILD] + '?';
571
- src[FULL] = '^' + FULLPLAIN + '$';
572
- // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
573
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
574
- // common in the npm registry.
575
- var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + '?' + src[BUILD] + '?';
576
- var LOOSE = R++;
577
- src[LOOSE] = '^' + LOOSEPLAIN + '$';
578
- var GTLT = R++;
579
- src[GTLT] = '((?:<|>)?=?)';
580
- // Something like "2.*" or "1.2.x".
581
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
582
- // Only the first item is strictly required.
583
- var XRANGEIDENTIFIERLOOSE = R++;
584
- src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
585
- var XRANGEIDENTIFIER = R++;
586
- src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*';
587
- var XRANGEPLAIN = R++;
588
- src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIER] + ')' + '(?:' + src[PRERELEASE] + ')?' + src[BUILD] + '?' + ')?)?';
589
- var XRANGEPLAINLOOSE = R++;
590
- src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' + '(?:' + src[PRERELEASELOOSE] + ')?' + src[BUILD] + '?' + ')?)?';
591
- var XRANGE = R++;
592
- src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$';
593
- var XRANGELOOSE = R++;
594
- src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$';
595
- // Coercion.
596
- // Extract anything that could conceivably be a part of a valid semver
597
- var COERCE = R++;
598
- src[COERCE] = '(?:^|[^\\d])' + '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + '(?:$|[^\\d])';
599
- // Tilde ranges.
600
- // Meaning is "reasonably at or greater than"
601
- var LONETILDE = R++;
602
- src[LONETILDE] = '(?:~>?)';
603
- var TILDETRIM = R++;
604
- src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+';
605
- re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g');
606
- safeRe[TILDETRIM] = new RegExp(makeSafeRe(src[TILDETRIM]), 'g');
607
- var tildeTrimReplace = '$1~';
608
- var TILDE = R++;
609
- src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$';
610
- var TILDELOOSE = R++;
611
- src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$';
612
- // Caret ranges.
613
- // Meaning is "at least and backwards compatible with"
614
- var LONECARET = R++;
615
- src[LONECARET] = '(?:\\^)';
616
- var CARETTRIM = R++;
617
- src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+';
618
- re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g');
619
- safeRe[CARETTRIM] = new RegExp(makeSafeRe(src[CARETTRIM]), 'g');
620
- var caretTrimReplace = '$1^';
621
- var CARET = R++;
622
- src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$';
623
- var CARETLOOSE = R++;
624
- src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$';
625
- // A simple gt/lt/eq thing, or just "" to indicate "any version"
626
- var COMPARATORLOOSE = R++;
627
- src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$';
628
- var COMPARATOR = R++;
629
- src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$';
630
- // An expression to strip any whitespace between the gtlt and the thing
631
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
632
- var COMPARATORTRIM = R++;
633
- src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] + '\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')';
634
- // this one has to use the /g flag
635
- re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g');
636
- safeRe[COMPARATORTRIM] = new RegExp(makeSafeRe(src[COMPARATORTRIM]), 'g');
637
- var comparatorTrimReplace = '$1$2$3';
638
- // Something like `1.2.3 - 1.2.4`
639
- // Note that these all use the loose form, because they'll be
640
- // checked against either the strict or loose comparator form
641
- // later.
642
- var HYPHENRANGE = R++;
643
- src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAIN] + ')' + '\\s*$';
644
- var HYPHENRANGELOOSE = R++;
645
- src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' + '\\s+-\\s+' + '(' + src[XRANGEPLAINLOOSE] + ')' + '\\s*$';
646
- // Star ranges basically just allow anything at all.
647
- var STAR = R++;
648
- src[STAR] = '(<|>)?=?\\s*\\*';
649
- // Compile to actual regexp objects.
650
- // All are flag-free, unless they were created above with a flag.
651
- for(var i = 0; i < R; i++){
652
- debug(i, src[i]);
653
- if (!re[i]) {
654
- re[i] = new RegExp(src[i]);
655
- // Replace all greedy whitespace to prevent regex dos issues. These regex are
656
- // used internally via the safeRe object since all inputs in this library get
657
- // normalized first to trim and collapse all extra whitespace. The original
658
- // regexes are exported for userland consumption and lower level usage. A
659
- // future breaking change could export the safer regex only with a note that
660
- // all input should have extra whitespace removed.
661
- safeRe[i] = new RegExp(makeSafeRe(src[i]));
662
- }
663
- }
664
- exports.parse = parse;
665
- function parse(version, options) {
666
- if (!options || (typeof options === "undefined" ? "undefined" : _type_of(options)) !== 'object') {
667
- options = {
668
- loose: !!options,
669
- includePrerelease: false
670
- };
671
- }
672
- if (_instanceof(version, SemVer)) {
673
- return version;
674
- }
675
- if (typeof version !== 'string') {
676
- return null;
677
- }
678
- if (version.length > MAX_LENGTH) {
679
- return null;
680
- }
681
- var r = options.loose ? safeRe[LOOSE] : safeRe[FULL];
682
- if (!r.test(version)) {
683
- return null;
684
- }
685
- try {
686
- return new SemVer(version, options);
687
- } catch (er) {
688
- return null;
689
- }
690
- }
691
- exports.valid = valid;
692
- function valid(version, options) {
693
- var v = parse(version, options);
694
- return v ? v.version : null;
695
- }
696
- exports.clean = clean;
697
- function clean(version, options) {
698
- var s = parse(version.trim().replace(/^[=v]+/, ''), options);
699
- return s ? s.version : null;
700
- }
701
- exports.SemVer = SemVer;
702
- function SemVer(version, options) {
703
- if (!options || (typeof options === "undefined" ? "undefined" : _type_of(options)) !== 'object') {
704
- options = {
705
- loose: !!options,
706
- includePrerelease: false
707
- };
708
- }
709
- if (_instanceof(version, SemVer)) {
710
- if (version.loose === options.loose) {
711
- return version;
712
- } else {
713
- version = version.version;
714
- }
715
- } else if (typeof version !== 'string') {
716
- throw new TypeError('Invalid Version: ' + version);
717
- }
718
- if (version.length > MAX_LENGTH) {
719
- throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters');
720
- }
721
- if (!_instanceof(this, SemVer)) {
722
- return new SemVer(version, options);
723
- }
724
- debug('SemVer', version, options);
725
- this.options = options;
726
- this.loose = !!options.loose;
727
- var m = version.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
728
- if (!m) {
729
- throw new TypeError('Invalid Version: ' + version);
730
- }
731
- this.raw = version;
732
- // these are actually numbers
733
- this.major = +m[1];
734
- this.minor = +m[2];
735
- this.patch = +m[3];
736
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
737
- throw new TypeError('Invalid major version');
738
- }
739
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
740
- throw new TypeError('Invalid minor version');
741
- }
742
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
743
- throw new TypeError('Invalid patch version');
744
- }
745
- // numberify any prerelease numeric ids
746
- if (!m[4]) {
747
- this.prerelease = [];
748
- } else {
749
- this.prerelease = m[4].split('.').map(function(id) {
750
- if (/^[0-9]+$/.test(id)) {
751
- var num = +id;
752
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
753
- return num;
754
- }
755
- }
756
- return id;
757
- });
758
- }
759
- this.build = m[5] ? m[5].split('.') : [];
760
- this.format();
761
- }
762
- SemVer.prototype.format = function() {
763
- this.version = this.major + '.' + this.minor + '.' + this.patch;
764
- if (this.prerelease.length) {
765
- this.version += '-' + this.prerelease.join('.');
766
- }
767
- return this.version;
768
- };
769
- SemVer.prototype.toString = function() {
770
- return this.version;
771
- };
772
- SemVer.prototype.compare = function(other) {
773
- debug('SemVer.compare', this.version, this.options, other);
774
- if (!_instanceof(other, SemVer)) {
775
- other = new SemVer(other, this.options);
776
- }
777
- return this.compareMain(other) || this.comparePre(other);
778
- };
779
- SemVer.prototype.compareMain = function(other) {
780
- if (!_instanceof(other, SemVer)) {
781
- other = new SemVer(other, this.options);
782
- }
783
- return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
784
- };
785
- SemVer.prototype.comparePre = function(other) {
786
- if (!_instanceof(other, SemVer)) {
787
- other = new SemVer(other, this.options);
788
- }
789
- // NOT having a prerelease is > having one
790
- if (this.prerelease.length && !other.prerelease.length) {
791
- return -1;
792
- } else if (!this.prerelease.length && other.prerelease.length) {
793
- return 1;
794
- } else if (!this.prerelease.length && !other.prerelease.length) {
795
- return 0;
796
- }
797
- var i = 0;
798
- do {
799
- var a = this.prerelease[i];
800
- var b = other.prerelease[i];
801
- debug('prerelease compare', i, a, b);
802
- if (a === undefined && b === undefined) {
803
- return 0;
804
- } else if (b === undefined) {
805
- return 1;
806
- } else if (a === undefined) {
807
- return -1;
808
- } else if (a === b) {
809
- continue;
810
- } else {
811
- return compareIdentifiers(a, b);
812
- }
813
- }while (++i);
814
- };
815
- // preminor will bump the version up to the next minor release, and immediately
816
- // down to pre-release. premajor and prepatch work the same way.
817
- SemVer.prototype.inc = function(release, identifier) {
818
- switch(release){
819
- case 'premajor':
820
- this.prerelease.length = 0;
821
- this.patch = 0;
822
- this.minor = 0;
823
- this.major++;
824
- this.inc('pre', identifier);
825
- break;
826
- case 'preminor':
827
- this.prerelease.length = 0;
828
- this.patch = 0;
829
- this.minor++;
830
- this.inc('pre', identifier);
831
- break;
832
- case 'prepatch':
833
- // If this is already a prerelease, it will bump to the next version
834
- // drop any prereleases that might already exist, since they are not
835
- // relevant at this point.
836
- this.prerelease.length = 0;
837
- this.inc('patch', identifier);
838
- this.inc('pre', identifier);
839
- break;
840
- // If the input is a non-prerelease version, this acts the same as
841
- // prepatch.
842
- case 'prerelease':
843
- if (this.prerelease.length === 0) {
844
- this.inc('patch', identifier);
845
- }
846
- this.inc('pre', identifier);
847
- break;
848
- case 'major':
849
- // If this is a pre-major version, bump up to the same major version.
850
- // Otherwise increment major.
851
- // 1.0.0-5 bumps to 1.0.0
852
- // 1.1.0 bumps to 2.0.0
853
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
854
- this.major++;
855
- }
856
- this.minor = 0;
857
- this.patch = 0;
858
- this.prerelease = [];
859
- break;
860
- case 'minor':
861
- // If this is a pre-minor version, bump up to the same minor version.
862
- // Otherwise increment minor.
863
- // 1.2.0-5 bumps to 1.2.0
864
- // 1.2.1 bumps to 1.3.0
865
- if (this.patch !== 0 || this.prerelease.length === 0) {
866
- this.minor++;
867
- }
868
- this.patch = 0;
869
- this.prerelease = [];
870
- break;
871
- case 'patch':
872
- // If this is not a pre-release version, it will increment the patch.
873
- // If it is a pre-release it will bump up to the same patch version.
874
- // 1.2.0-5 patches to 1.2.0
875
- // 1.2.0 patches to 1.2.1
876
- if (this.prerelease.length === 0) {
877
- this.patch++;
878
- }
879
- this.prerelease = [];
880
- break;
881
- // This probably shouldn't be used publicly.
882
- // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
883
- case 'pre':
884
- if (this.prerelease.length === 0) {
885
- this.prerelease = [
886
- 0
887
- ];
888
- } else {
889
- var i = this.prerelease.length;
890
- while(--i >= 0){
891
- if (typeof this.prerelease[i] === 'number') {
892
- this.prerelease[i]++;
893
- i = -2;
894
- }
895
- }
896
- if (i === -1) {
897
- // didn't increment anything
898
- this.prerelease.push(0);
899
- }
900
- }
901
- if (identifier) {
902
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
903
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
904
- if (this.prerelease[0] === identifier) {
905
- if (isNaN(this.prerelease[1])) {
906
- this.prerelease = [
907
- identifier,
908
- 0
909
- ];
910
- }
911
- } else {
912
- this.prerelease = [
913
- identifier,
914
- 0
915
- ];
916
- }
917
- }
918
- break;
919
- default:
920
- throw new Error('invalid increment argument: ' + release);
921
- }
922
- this.format();
923
- this.raw = this.version;
924
- return this;
925
- };
926
- exports.inc = inc;
927
- function inc(version, release, loose, identifier) {
928
- if (typeof loose === 'string') {
929
- identifier = loose;
930
- loose = undefined;
931
- }
932
- try {
933
- return new SemVer(version, loose).inc(release, identifier).version;
934
- } catch (er) {
935
- return null;
936
- }
937
- }
938
- exports.diff = diff;
939
- function diff(version1, version2) {
940
- if (eq(version1, version2)) {
941
- return null;
942
- } else {
943
- var v1 = parse(version1);
944
- var v2 = parse(version2);
945
- var prefix = '';
946
- if (v1.prerelease.length || v2.prerelease.length) {
947
- prefix = 'pre';
948
- var defaultResult = 'prerelease';
949
- }
950
- for(var key in v1){
951
- if (key === 'major' || key === 'minor' || key === 'patch') {
952
- if (v1[key] !== v2[key]) {
953
- return prefix + key;
954
- }
955
- }
956
- }
957
- return defaultResult // may be undefined
958
- ;
959
- }
960
- }
961
- exports.compareIdentifiers = compareIdentifiers;
962
- var numeric = /^[0-9]+$/;
963
- function compareIdentifiers(a, b) {
964
- var anum = numeric.test(a);
965
- var bnum = numeric.test(b);
966
- if (anum && bnum) {
967
- a = +a;
968
- b = +b;
969
- }
970
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
971
- }
972
- exports.rcompareIdentifiers = rcompareIdentifiers;
973
- function rcompareIdentifiers(a, b) {
974
- return compareIdentifiers(b, a);
975
- }
976
- exports.major = major;
977
- function major(a, loose) {
978
- return new SemVer(a, loose).major;
979
- }
980
- exports.minor = minor;
981
- function minor(a, loose) {
982
- return new SemVer(a, loose).minor;
983
- }
984
- exports.patch = patch;
985
- function patch(a, loose) {
986
- return new SemVer(a, loose).patch;
987
- }
988
- exports.compare = compare;
989
- function compare(a, b, loose) {
990
- return new SemVer(a, loose).compare(new SemVer(b, loose));
991
- }
992
- exports.compareLoose = compareLoose;
993
- function compareLoose(a, b) {
994
- return compare(a, b, true);
995
- }
996
- exports.rcompare = rcompare;
997
- function rcompare(a, b, loose) {
998
- return compare(b, a, loose);
999
- }
1000
- exports.sort = sort;
1001
- function sort(list, loose) {
1002
- return list.sort(function(a, b) {
1003
- return exports.compare(a, b, loose);
1004
- });
1005
- }
1006
- exports.rsort = rsort;
1007
- function rsort(list, loose) {
1008
- return list.sort(function(a, b) {
1009
- return exports.rcompare(a, b, loose);
1010
- });
1011
- }
1012
- exports.gt = gt;
1013
- function gt(a, b, loose) {
1014
- return compare(a, b, loose) > 0;
1015
- }
1016
- exports.lt = lt;
1017
- function lt(a, b, loose) {
1018
- return compare(a, b, loose) < 0;
1019
- }
1020
- exports.eq = eq;
1021
- function eq(a, b, loose) {
1022
- return compare(a, b, loose) === 0;
1023
- }
1024
- exports.neq = neq;
1025
- function neq(a, b, loose) {
1026
- return compare(a, b, loose) !== 0;
1027
- }
1028
- exports.gte = gte;
1029
- function gte(a, b, loose) {
1030
- return compare(a, b, loose) >= 0;
1031
- }
1032
- exports.lte = lte;
1033
- function lte(a, b, loose) {
1034
- return compare(a, b, loose) <= 0;
1035
- }
1036
- exports.cmp = cmp;
1037
- function cmp(a, op, b, loose) {
1038
- switch(op){
1039
- case '===':
1040
- if ((typeof a === "undefined" ? "undefined" : _type_of(a)) === 'object') a = a.version;
1041
- if ((typeof b === "undefined" ? "undefined" : _type_of(b)) === 'object') b = b.version;
1042
- return a === b;
1043
- case '!==':
1044
- if ((typeof a === "undefined" ? "undefined" : _type_of(a)) === 'object') a = a.version;
1045
- if ((typeof b === "undefined" ? "undefined" : _type_of(b)) === 'object') b = b.version;
1046
- return a !== b;
1047
- case '':
1048
- case '=':
1049
- case '==':
1050
- return eq(a, b, loose);
1051
- case '!=':
1052
- return neq(a, b, loose);
1053
- case '>':
1054
- return gt(a, b, loose);
1055
- case '>=':
1056
- return gte(a, b, loose);
1057
- case '<':
1058
- return lt(a, b, loose);
1059
- case '<=':
1060
- return lte(a, b, loose);
1061
- default:
1062
- throw new TypeError('Invalid operator: ' + op);
1063
- }
1064
- }
1065
- exports.Comparator = Comparator;
1066
- function Comparator(comp, options) {
1067
- if (!options || (typeof options === "undefined" ? "undefined" : _type_of(options)) !== 'object') {
1068
- options = {
1069
- loose: !!options,
1070
- includePrerelease: false
1071
- };
1072
- }
1073
- if (_instanceof(comp, Comparator)) {
1074
- if (comp.loose === !!options.loose) {
1075
- return comp;
1076
- } else {
1077
- comp = comp.value;
1078
- }
1079
- }
1080
- if (!_instanceof(this, Comparator)) {
1081
- return new Comparator(comp, options);
1082
- }
1083
- comp = comp.trim().split(/\s+/).join(' ');
1084
- debug('comparator', comp, options);
1085
- this.options = options;
1086
- this.loose = !!options.loose;
1087
- this.parse(comp);
1088
- if (this.semver === ANY) {
1089
- this.value = '';
1090
- } else {
1091
- this.value = this.operator + this.semver.version;
1092
- }
1093
- debug('comp', this);
1094
- }
1095
- var ANY = {};
1096
- Comparator.prototype.parse = function(comp) {
1097
- var r = this.options.loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
1098
- var m = comp.match(r);
1099
- if (!m) {
1100
- throw new TypeError('Invalid comparator: ' + comp);
1101
- }
1102
- this.operator = m[1];
1103
- if (this.operator === '=') {
1104
- this.operator = '';
1105
- }
1106
- // if it literally is just '>' or '' then allow anything.
1107
- if (!m[2]) {
1108
- this.semver = ANY;
1109
- } else {
1110
- this.semver = new SemVer(m[2], this.options.loose);
1111
- }
1112
- };
1113
- Comparator.prototype.toString = function() {
1114
- return this.value;
1115
- };
1116
- Comparator.prototype.test = function(version) {
1117
- debug('Comparator.test', version, this.options.loose);
1118
- if (this.semver === ANY) {
1119
- return true;
1120
- }
1121
- if (typeof version === 'string') {
1122
- version = new SemVer(version, this.options);
1123
- }
1124
- return cmp(version, this.operator, this.semver, this.options);
1125
- };
1126
- Comparator.prototype.intersects = function(comp, options) {
1127
- if (!_instanceof(comp, Comparator)) {
1128
- throw new TypeError('a Comparator is required');
1129
- }
1130
- if (!options || (typeof options === "undefined" ? "undefined" : _type_of(options)) !== 'object') {
1131
- options = {
1132
- loose: !!options,
1133
- includePrerelease: false
1134
- };
1135
- }
1136
- var rangeTmp;
1137
- if (this.operator === '') {
1138
- rangeTmp = new Range(comp.value, options);
1139
- return satisfies(this.value, rangeTmp, options);
1140
- } else if (comp.operator === '') {
1141
- rangeTmp = new Range(this.value, options);
1142
- return satisfies(comp.semver, rangeTmp, options);
1143
- }
1144
- var sameDirectionIncreasing = (this.operator === '>=' || this.operator === '>') && (comp.operator === '>=' || comp.operator === '>');
1145
- var sameDirectionDecreasing = (this.operator === '<=' || this.operator === '<') && (comp.operator === '<=' || comp.operator === '<');
1146
- var sameSemVer = this.semver.version === comp.semver.version;
1147
- var differentDirectionsInclusive = (this.operator === '>=' || this.operator === '<=') && (comp.operator === '>=' || comp.operator === '<=');
1148
- var oppositeDirectionsLessThan = cmp(this.semver, '<', comp.semver, options) && (this.operator === '>=' || this.operator === '>') && (comp.operator === '<=' || comp.operator === '<');
1149
- var oppositeDirectionsGreaterThan = cmp(this.semver, '>', comp.semver, options) && (this.operator === '<=' || this.operator === '<') && (comp.operator === '>=' || comp.operator === '>');
1150
- return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
1151
- };
1152
- exports.Range = Range;
1153
- function Range(range, options) {
1154
- if (!options || (typeof options === "undefined" ? "undefined" : _type_of(options)) !== 'object') {
1155
- options = {
1156
- loose: !!options,
1157
- includePrerelease: false
1158
- };
1159
- }
1160
- if (_instanceof(range, Range)) {
1161
- if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
1162
- return range;
1163
- } else {
1164
- return new Range(range.raw, options);
1165
- }
1166
- }
1167
- if (_instanceof(range, Comparator)) {
1168
- return new Range(range.value, options);
1169
- }
1170
- if (!_instanceof(this, Range)) {
1171
- return new Range(range, options);
1172
- }
1173
- this.options = options;
1174
- this.loose = !!options.loose;
1175
- this.includePrerelease = !!options.includePrerelease;
1176
- // First reduce all whitespace as much as possible so we do not have to rely
1177
- // on potentially slow regexes like \s*. This is then stored and used for
1178
- // future error messages as well.
1179
- this.raw = range.trim().split(/\s+/).join(' ');
1180
- // First, split based on boolean or ||
1181
- this.set = this.raw.split('||').map(function(range) {
1182
- return this.parseRange(range.trim());
1183
- }, this).filter(function(c) {
1184
- // throw out any that are not relevant for whatever reason
1185
- return c.length;
1186
- });
1187
- if (!this.set.length) {
1188
- throw new TypeError('Invalid SemVer Range: ' + this.raw);
1189
- }
1190
- this.format();
1191
- }
1192
- Range.prototype.format = function() {
1193
- this.range = this.set.map(function(comps) {
1194
- return comps.join(' ').trim();
1195
- }).join('||').trim();
1196
- return this.range;
1197
- };
1198
- Range.prototype.toString = function() {
1199
- return this.range;
1200
- };
1201
- Range.prototype.parseRange = function(range) {
1202
- var loose = this.options.loose;
1203
- // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1204
- var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
1205
- range = range.replace(hr, hyphenReplace);
1206
- debug('hyphen replace', range);
1207
- // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1208
- range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
1209
- debug('comparator trim', range, safeRe[COMPARATORTRIM]);
1210
- // `~ 1.2.3` => `~1.2.3`
1211
- range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
1212
- // `^ 1.2.3` => `^1.2.3`
1213
- range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
1214
- // At this point, the range is completely trimmed and
1215
- // ready to be split into comparators.
1216
- var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
1217
- var set = range.split(' ').map(function(comp) {
1218
- return parseComparator(comp, this.options);
1219
- }, this).join(' ').split(/\s+/);
1220
- if (this.options.loose) {
1221
- // in loose mode, throw out any that are not valid comparators
1222
- set = set.filter(function(comp) {
1223
- return !!comp.match(compRe);
1224
- });
1225
- }
1226
- set = set.map(function(comp) {
1227
- return new Comparator(comp, this.options);
1228
- }, this);
1229
- return set;
1230
- };
1231
- Range.prototype.intersects = function(range, options) {
1232
- if (!_instanceof(range, Range)) {
1233
- throw new TypeError('a Range is required');
1234
- }
1235
- return this.set.some(function(thisComparators) {
1236
- return thisComparators.every(function(thisComparator) {
1237
- return range.set.some(function(rangeComparators) {
1238
- return rangeComparators.every(function(rangeComparator) {
1239
- return thisComparator.intersects(rangeComparator, options);
1240
- });
1241
- });
1242
- });
1243
- });
1244
- };
1245
- // Mostly just for testing and legacy API reasons
1246
- exports.toComparators = toComparators;
1247
- function toComparators(range, options) {
1248
- return new Range(range, options).set.map(function(comp) {
1249
- return comp.map(function(c) {
1250
- return c.value;
1251
- }).join(' ').trim().split(' ');
1252
- });
1253
- }
1254
- // comprised of xranges, tildes, stars, and gtlt's at this point.
1255
- // already replaced the hyphen ranges
1256
- // turn into a set of JUST comparators.
1257
- function parseComparator(comp, options) {
1258
- debug('comp', comp, options);
1259
- comp = replaceCarets(comp, options);
1260
- debug('caret', comp);
1261
- comp = replaceTildes(comp, options);
1262
- debug('tildes', comp);
1263
- comp = replaceXRanges(comp, options);
1264
- debug('xrange', comp);
1265
- comp = replaceStars(comp, options);
1266
- debug('stars', comp);
1267
- return comp;
1268
- }
1269
- function isX(id) {
1270
- return !id || id.toLowerCase() === 'x' || id === '*';
1271
- }
1272
- // ~, ~> --> * (any, kinda silly)
1273
- // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
1274
- // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
1275
- // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
1276
- // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
1277
- // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
1278
- function replaceTildes(comp, options) {
1279
- return comp.trim().split(/\s+/).map(function(comp) {
1280
- return replaceTilde(comp, options);
1281
- }).join(' ');
1282
- }
1283
- function replaceTilde(comp, options) {
1284
- var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
1285
- return comp.replace(r, function(_, M, m, p, pr) {
1286
- debug('tilde', comp, _, M, m, p, pr);
1287
- var ret;
1288
- if (isX(M)) {
1289
- ret = '';
1290
- } else if (isX(m)) {
1291
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1292
- } else if (isX(p)) {
1293
- // ~1.2 == >=1.2.0 <1.3.0
1294
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1295
- } else if (pr) {
1296
- debug('replaceTilde pr', pr);
1297
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
1298
- } else {
1299
- // ~1.2.3 == >=1.2.3 <1.3.0
1300
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
1301
- }
1302
- debug('tilde return', ret);
1303
- return ret;
1304
- });
1305
- }
1306
- // ^ --> * (any, kinda silly)
1307
- // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
1308
- // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
1309
- // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
1310
- // ^1.2.3 --> >=1.2.3 <2.0.0
1311
- // ^1.2.0 --> >=1.2.0 <2.0.0
1312
- function replaceCarets(comp, options) {
1313
- return comp.trim().split(/\s+/).map(function(comp) {
1314
- return replaceCaret(comp, options);
1315
- }).join(' ');
1316
- }
1317
- function replaceCaret(comp, options) {
1318
- debug('caret', comp, options);
1319
- var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
1320
- return comp.replace(r, function(_, M, m, p, pr) {
1321
- debug('caret', comp, _, M, m, p, pr);
1322
- var ret;
1323
- if (isX(M)) {
1324
- ret = '';
1325
- } else if (isX(m)) {
1326
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1327
- } else if (isX(p)) {
1328
- if (M === '0') {
1329
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1330
- } else {
1331
- ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
1332
- }
1333
- } else if (pr) {
1334
- debug('replaceCaret pr', pr);
1335
- if (M === '0') {
1336
- if (m === '0') {
1337
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + m + '.' + (+p + 1);
1338
- } else {
1339
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + M + '.' + (+m + 1) + '.0';
1340
- }
1341
- } else {
1342
- ret = '>=' + M + '.' + m + '.' + p + '-' + pr + ' <' + (+M + 1) + '.0.0';
1343
- }
1344
- } else {
1345
- debug('no pr');
1346
- if (M === '0') {
1347
- if (m === '0') {
1348
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + m + '.' + (+p + 1);
1349
- } else {
1350
- ret = '>=' + M + '.' + m + '.' + p + ' <' + M + '.' + (+m + 1) + '.0';
1351
- }
1352
- } else {
1353
- ret = '>=' + M + '.' + m + '.' + p + ' <' + (+M + 1) + '.0.0';
1354
- }
1355
- }
1356
- debug('caret return', ret);
1357
- return ret;
1358
- });
1359
- }
1360
- function replaceXRanges(comp, options) {
1361
- debug('replaceXRanges', comp, options);
1362
- return comp.split(/\s+/).map(function(comp) {
1363
- return replaceXRange(comp, options);
1364
- }).join(' ');
1365
- }
1366
- function replaceXRange(comp, options) {
1367
- comp = comp.trim();
1368
- var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
1369
- return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
1370
- debug('xRange', comp, ret, gtlt, M, m, p, pr);
1371
- var xM = isX(M);
1372
- var xm = xM || isX(m);
1373
- var xp = xm || isX(p);
1374
- var anyX = xp;
1375
- if (gtlt === '=' && anyX) {
1376
- gtlt = '';
1377
- }
1378
- if (xM) {
1379
- if (gtlt === '>' || gtlt === '<') {
1380
- // nothing is allowed
1381
- ret = '<0.0.0';
1382
- } else {
1383
- // nothing is forbidden
1384
- ret = '*';
1385
- }
1386
- } else if (gtlt && anyX) {
1387
- // we know patch is an x, because we have any x at all.
1388
- // replace X with 0
1389
- if (xm) {
1390
- m = 0;
1391
- }
1392
- p = 0;
1393
- if (gtlt === '>') {
1394
- // >1 => >=2.0.0
1395
- // >1.2 => >=1.3.0
1396
- // >1.2.3 => >= 1.2.4
1397
- gtlt = '>=';
1398
- if (xm) {
1399
- M = +M + 1;
1400
- m = 0;
1401
- p = 0;
1402
- } else {
1403
- m = +m + 1;
1404
- p = 0;
1405
- }
1406
- } else if (gtlt === '<=') {
1407
- // <=0.7.x is actually <0.8.0, since any 0.7.x should
1408
- // pass. Similarly, <=7.x is actually <8.0.0, etc.
1409
- gtlt = '<';
1410
- if (xm) {
1411
- M = +M + 1;
1412
- } else {
1413
- m = +m + 1;
1414
- }
1415
- }
1416
- ret = gtlt + M + '.' + m + '.' + p;
1417
- } else if (xm) {
1418
- ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1419
- } else if (xp) {
1420
- ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1421
- }
1422
- debug('xRange return', ret);
1423
- return ret;
1424
- });
1425
- }
1426
- // Because * is AND-ed with everything else in the comparator,
1427
- // and '' means "any version", just remove the *s entirely.
1428
- function replaceStars(comp, options) {
1429
- debug('replaceStars', comp, options);
1430
- // Looseness is ignored here. star is always as loose as it gets!
1431
- return comp.trim().replace(safeRe[STAR], '');
1432
- }
1433
- // This function is passed to string.replace(safeRe[HYPHENRANGE])
1434
- // M, m, patch, prerelease, build
1435
- // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1436
- // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
1437
- // 1.2 - 3.4 => >=1.2.0 <3.5.0
1438
- function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
1439
- if (isX(fM)) {
1440
- from = '';
1441
- } else if (isX(fm)) {
1442
- from = '>=' + fM + '.0.0';
1443
- } else if (isX(fp)) {
1444
- from = '>=' + fM + '.' + fm + '.0';
1445
- } else {
1446
- from = '>=' + from;
1447
- }
1448
- if (isX(tM)) {
1449
- to = '';
1450
- } else if (isX(tm)) {
1451
- to = '<' + (+tM + 1) + '.0.0';
1452
- } else if (isX(tp)) {
1453
- to = '<' + tM + '.' + (+tm + 1) + '.0';
1454
- } else if (tpr) {
1455
- to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
1456
- } else {
1457
- to = '<=' + to;
1458
- }
1459
- return (from + ' ' + to).trim();
1460
- }
1461
- // if ANY of the sets match ALL of its comparators, then pass
1462
- Range.prototype.test = function(version) {
1463
- if (!version) {
1464
- return false;
1465
- }
1466
- if (typeof version === 'string') {
1467
- version = new SemVer(version, this.options);
1468
- }
1469
- for(var i = 0; i < this.set.length; i++){
1470
- if (testSet(this.set[i], version, this.options)) {
1471
- return true;
1472
- }
1473
- }
1474
- return false;
1475
- };
1476
- function testSet(set, version, options) {
1477
- for(var i = 0; i < set.length; i++){
1478
- if (!set[i].test(version)) {
1479
- return false;
1480
- }
1481
- }
1482
- if (version.prerelease.length && !options.includePrerelease) {
1483
- // Find the set of versions that are allowed to have prereleases
1484
- // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1485
- // That should allow `1.2.3-pr.2` to pass.
1486
- // However, `1.2.4-alpha.notready` should NOT be allowed,
1487
- // even though it's within the range set by the comparators.
1488
- for(i = 0; i < set.length; i++){
1489
- debug(set[i].semver);
1490
- if (set[i].semver === ANY) {
1491
- continue;
1492
- }
1493
- if (set[i].semver.prerelease.length > 0) {
1494
- var allowed = set[i].semver;
1495
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
1496
- return true;
1497
- }
1498
- }
1499
- }
1500
- // Version has a -pre, but it's not one of the ones we like.
1501
- return false;
1502
- }
1503
- return true;
1504
- }
1505
- exports.satisfies = satisfies;
1506
- function satisfies(version, range, options) {
1507
- try {
1508
- range = new Range(range, options);
1509
- } catch (er) {
1510
- return false;
1511
- }
1512
- return range.test(version);
1513
- }
1514
- exports.maxSatisfying = maxSatisfying;
1515
- function maxSatisfying(versions, range, options) {
1516
- var max = null;
1517
- var maxSV = null;
1518
- try {
1519
- var rangeObj = new Range(range, options);
1520
- } catch (er) {
1521
- return null;
1522
- }
1523
- versions.forEach(function(v) {
1524
- if (rangeObj.test(v)) {
1525
- // satisfies(v, range, options)
1526
- if (!max || maxSV.compare(v) === -1) {
1527
- // compare(max, v, true)
1528
- max = v;
1529
- maxSV = new SemVer(max, options);
1530
- }
1531
- }
1532
- });
1533
- return max;
1534
- }
1535
- exports.minSatisfying = minSatisfying;
1536
- function minSatisfying(versions, range, options) {
1537
- var min = null;
1538
- var minSV = null;
1539
- try {
1540
- var rangeObj = new Range(range, options);
1541
- } catch (er) {
1542
- return null;
1543
- }
1544
- versions.forEach(function(v) {
1545
- if (rangeObj.test(v)) {
1546
- // satisfies(v, range, options)
1547
- if (!min || minSV.compare(v) === 1) {
1548
- // compare(min, v, true)
1549
- min = v;
1550
- minSV = new SemVer(min, options);
1551
- }
1552
- }
1553
- });
1554
- return min;
1555
- }
1556
- exports.minVersion = minVersion;
1557
- function minVersion(range, loose) {
1558
- range = new Range(range, loose);
1559
- var minver = new SemVer('0.0.0');
1560
- if (range.test(minver)) {
1561
- return minver;
1562
- }
1563
- minver = new SemVer('0.0.0-0');
1564
- if (range.test(minver)) {
1565
- return minver;
1566
- }
1567
- minver = null;
1568
- for(var i = 0; i < range.set.length; ++i){
1569
- var comparators = range.set[i];
1570
- comparators.forEach(function(comparator) {
1571
- // Clone to avoid manipulating the comparator's semver object.
1572
- var compver = new SemVer(comparator.semver.version);
1573
- switch(comparator.operator){
1574
- case '>':
1575
- if (compver.prerelease.length === 0) {
1576
- compver.patch++;
1577
- } else {
1578
- compver.prerelease.push(0);
1579
- }
1580
- compver.raw = compver.format();
1581
- /* fallthrough */ case '':
1582
- case '>=':
1583
- if (!minver || gt(minver, compver)) {
1584
- minver = compver;
1585
- }
1586
- break;
1587
- case '<':
1588
- case '<=':
1589
- break;
1590
- /* istanbul ignore next */ default:
1591
- throw new Error('Unexpected operation: ' + comparator.operator);
1592
- }
1593
- });
1594
- }
1595
- if (minver && range.test(minver)) {
1596
- return minver;
1597
- }
1598
- return null;
1599
- }
1600
- exports.validRange = validRange;
1601
- function validRange(range, options) {
1602
- try {
1603
- // Return '*' instead of '' so that truthiness works.
1604
- // This will throw if it's invalid anyway
1605
- return new Range(range, options).range || '*';
1606
- } catch (er) {
1607
- return null;
1608
- }
1609
- }
1610
- // Determine if version is less than all the versions possible in the range
1611
- exports.ltr = ltr;
1612
- function ltr(version, range, options) {
1613
- return outside(version, range, '<', options);
1614
- }
1615
- // Determine if version is greater than all the versions possible in the range.
1616
- exports.gtr = gtr;
1617
- function gtr(version, range, options) {
1618
- return outside(version, range, '>', options);
1619
- }
1620
- exports.outside = outside;
1621
- function outside(version, range, hilo, options) {
1622
- version = new SemVer(version, options);
1623
- range = new Range(range, options);
1624
- var gtfn, ltefn, ltfn, comp, ecomp;
1625
- switch(hilo){
1626
- case '>':
1627
- gtfn = gt;
1628
- ltefn = lte;
1629
- ltfn = lt;
1630
- comp = '>';
1631
- ecomp = '>=';
1632
- break;
1633
- case '<':
1634
- gtfn = lt;
1635
- ltefn = gte;
1636
- ltfn = gt;
1637
- comp = '<';
1638
- ecomp = '<=';
1639
- break;
1640
- default:
1641
- throw new TypeError('Must provide a hilo val of "<" or ">"');
1642
- }
1643
- // If it satisifes the range it is not outside
1644
- if (satisfies(version, range, options)) {
1645
- return false;
1646
- }
1647
- // From now on, variable terms are as if we're in "gtr" mode.
1648
- // but note that everything is flipped for the "ltr" function.
1649
- for(var i = 0; i < range.set.length; ++i){
1650
- var comparators = range.set[i];
1651
- var high = null;
1652
- var low = null;
1653
- comparators.forEach(function(comparator) {
1654
- if (comparator.semver === ANY) {
1655
- comparator = new Comparator('>=0.0.0');
1656
- }
1657
- high = high || comparator;
1658
- low = low || comparator;
1659
- if (gtfn(comparator.semver, high.semver, options)) {
1660
- high = comparator;
1661
- } else if (ltfn(comparator.semver, low.semver, options)) {
1662
- low = comparator;
1663
- }
1664
- });
1665
- // If the edge version comparator has a operator then our version
1666
- // isn't outside it
1667
- if (high.operator === comp || high.operator === ecomp) {
1668
- return false;
1669
- }
1670
- // If the lowest version comparator has an operator and our version
1671
- // is less than it then it isn't higher than the range
1672
- if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
1673
- return false;
1674
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1675
- return false;
1676
- }
1677
- }
1678
- return true;
1679
- }
1680
- exports.prerelease = prerelease;
1681
- function prerelease(version, options) {
1682
- var parsed = parse(version, options);
1683
- return parsed && parsed.prerelease.length ? parsed.prerelease : null;
1684
- }
1685
- exports.intersects = intersects;
1686
- function intersects(r1, r2, options) {
1687
- r1 = new Range(r1, options);
1688
- r2 = new Range(r2, options);
1689
- return r1.intersects(r2);
1690
- }
1691
- exports.coerce = coerce;
1692
- function coerce(version) {
1693
- if (_instanceof(version, SemVer)) {
1694
- return version;
1695
- }
1696
- if (typeof version !== 'string') {
1697
- return null;
1698
- }
1699
- var match = version.match(safeRe[COERCE]);
1700
- if (match == null) {
1701
- return null;
1702
- }
1703
- return parse(match[1] + '.' + (match[2] || '0') + '.' + (match[3] || '0'));
1704
- }
1705
- })(semver, semver.exports);
1706
- return semver.exports;
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());
1707
459
  }
1708
460
 
1709
- var parse_1;
1710
- var hasRequiredParse;
1711
- function requireParse() {
1712
- if (hasRequiredParse) return parse_1;
1713
- hasRequiredParse = 1;
1714
- var path = require$$0$1;
1715
- var niceTry = requireSrc$1();
1716
- var resolveCommand = requireResolveCommand();
1717
- var escape = require_escape();
1718
- var readShebang = requireReadShebang();
1719
- var semver = requireSemver();
1720
- var isWin = process.platform === 'win32';
1721
- var isExecutableRegExp = /\.(?:com|exe)$/i;
1722
- var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
1723
- // `options.shell` is supported in Node ^4.8.0, ^5.7.0 and >= 6.0.0
1724
- var supportsShellOption = niceTry(function() {
1725
- return semver.satisfies(process.version, '^4.8.0 || ^5.7.0 || >= 6.0.0', true);
1726
- }) || false;
1727
- function detectShebang(parsed) {
1728
- parsed.file = resolveCommand(parsed);
1729
- var shebang = parsed.file && readShebang(parsed.file);
1730
- if (shebang) {
1731
- parsed.args.unshift(parsed.file);
1732
- parsed.command = shebang;
1733
- return resolveCommand(parsed);
1734
- }
1735
- return parsed.file;
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);
1736
484
  }
1737
- function parseNonShell(parsed) {
1738
- if (!isWin) {
1739
- return parsed;
1740
- }
1741
- // Detect & add support for shebangs
1742
- var commandFile = detectShebang(parsed);
1743
- // We don't need a shell if the command filename is an executable
1744
- var needsShell = !isExecutableRegExp.test(commandFile);
1745
- // If a shell is required, use cmd.exe and take care of escaping everything correctly
1746
- // Note that `forceShell` is an hidden option used only in tests
1747
- if (parsed.options.forceShell || needsShell) {
1748
- // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
1749
- // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
1750
- // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
1751
- // we need to double escape them
1752
- var needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
1753
- // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
1754
- // This is necessary otherwise it will always fail with ENOENT in those cases
1755
- parsed.command = path.normalize(parsed.command);
1756
- // Escape command & arguments
1757
- parsed.command = escape.command(parsed.command);
1758
- parsed.args = parsed.args.map(function(arg) {
1759
- return escape.argument(arg, needsDoubleEscapeMetaChars);
1760
- });
1761
- var shellCommand = [
1762
- parsed.command
1763
- ].concat(parsed.args).join(' ');
1764
- parsed.args = [
1765
- '/d',
1766
- '/s',
1767
- '/c',
1768
- '"'.concat(shellCommand, '"')
1769
- ];
1770
- parsed.command = process.env.comspec || 'cmd.exe';
1771
- parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
1772
- }
485
+
486
+ return parsed.file;
487
+ }
488
+
489
+ var NODES = ['node', 'node.exe', 'node.cmd'];
490
+
491
+ function parseNonShell(parsed) {
492
+ if (!isWin$1) {
1773
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
1774
522
  }
1775
- function parseShell(parsed) {
1776
- // If node supports the shell option, there's no need to mimic its behavior
1777
- if (supportsShellOption) {
1778
- return parsed;
1779
- }
1780
- // Mimic node shell option
1781
- // See https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335
1782
- var shellCommand = [
1783
- parsed.command
1784
- ].concat(parsed.args).join(' ');
1785
- if (isWin) {
1786
- parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe';
1787
- parsed.args = [
1788
- '/d',
1789
- '/s',
1790
- '/c',
1791
- '"'.concat(shellCommand, '"')
1792
- ];
1793
- parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
1794
- } else {
1795
- if (typeof parsed.options.shell === 'string') {
1796
- parsed.command = parsed.options.shell;
1797
- } else if (process.platform === 'android') {
1798
- parsed.command = '/system/bin/sh';
1799
- } else {
1800
- parsed.command = '/bin/sh';
1801
- }
1802
- parsed.args = [
1803
- '-c',
1804
- shellCommand
1805
- ];
1806
- }
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) {
1807
530
  return parsed;
1808
- }
1809
- function parse(command, args, options) {
1810
- // Normalize arguments, similar to nodejs
1811
- if (args && !Array.isArray(args)) {
1812
- options = args;
1813
- args = null;
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';
1814
548
  }
1815
- args = args ? args.slice(0) : []; // Clone array to avoid changing the original
1816
- options = Object.assign({}, options); // Clone object to avoid changing the original
1817
- // Build our parsed object
1818
- var parsed = {
1819
- command: command,
1820
- args: args,
1821
- options: options,
1822
- file: undefined,
1823
- original: {
1824
- command: command,
1825
- args: args
1826
- }
1827
- };
1828
- // Delegate further parsing to shell or non-shell
1829
- return options.shell ? parseShell(parsed) : parseNonShell(parsed);
549
+
550
+ parsed.args = ['-c', shellCommand];
1830
551
  }
1831
- parse_1 = parse;
1832
- return parse_1;
552
+
553
+ return parsed;
1833
554
  }
1834
555
 
1835
- var enoent;
1836
- var hasRequiredEnoent;
1837
- function requireEnoent() {
1838
- if (hasRequiredEnoent) return enoent;
1839
- hasRequiredEnoent = 1;
1840
- var isWin = process.platform === 'win32';
1841
- function notFoundError(original, syscall) {
1842
- return Object.assign(new Error("".concat(syscall, " ").concat(original.command, " ENOENT")), {
1843
- code: 'ENOENT',
1844
- errno: 'ENOENT',
1845
- syscall: "".concat(syscall, " ").concat(original.command),
1846
- path: original.command,
1847
- spawnargs: original.args
1848
- });
1849
- }
1850
- function hookChildProcess(cp, parsed) {
1851
- if (!isWin) {
1852
- return;
1853
- }
1854
- var originalEmit = cp.emit;
1855
- cp.emit = function(name, arg1) {
1856
- // If emitting "exit" event and exit code is 1, we need to check if
1857
- // the command exists and emit an "error" instead
1858
- // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
1859
- if (name === 'exit') {
1860
- var err = verifyENOENT(arg1, parsed);
1861
- if (err) {
1862
- return originalEmit.call(cp, 'error', err);
1863
- }
1864
- }
1865
- return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
1866
- };
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;
1867
561
  }
1868
- function verifyENOENT(status, parsed) {
1869
- if (isWin && status === 1 && !parsed.file) {
1870
- return notFoundError(parsed.original, 'spawn');
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
1871
576
  }
1872
- return null;
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;
1873
598
  }
1874
- function verifyENOENTSync(status, parsed) {
1875
- if (isWin && status === 1 && !parsed.file) {
1876
- return notFoundError(parsed.original, 'spawnSync');
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
+ }
1877
612
  }
1878
- return null;
1879
- }
1880
- enoent = {
1881
- hookChildProcess: hookChildProcess,
1882
- verifyENOENT: verifyENOENT,
1883
- verifyENOENTSync: verifyENOENTSync,
1884
- notFoundError: notFoundError
613
+
614
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
1885
615
  };
1886
- return enoent;
1887
616
  }
1888
617
 
1889
- var hasRequiredCrossSpawn6_0_5;
1890
- function requireCrossSpawn6_0_5() {
1891
- if (hasRequiredCrossSpawn6_0_5) return crossSpawn6_0_5.exports;
1892
- hasRequiredCrossSpawn6_0_5 = 1;
1893
- var cp = require$$0$2;
1894
- var parse = requireParse();
1895
- var enoent = requireEnoent();
1896
- function spawn(command, args, options) {
1897
- // Parse the arguments
1898
- var parsed = parse(command, args, options);
1899
- // Spawn the child process
1900
- var spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1901
- // Hook into child process "exit" event to emit an error if the command
1902
- // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
1903
- enoent.hookChildProcess(spawned, parsed);
1904
- return spawned;
618
+ function verifyENOENT(status, parsed) {
619
+ if (isWin && status === 1 && !parsed.file) {
620
+ return notFoundError(parsed.original, 'spawn');
1905
621
  }
1906
- function spawnSync(command, args, options) {
1907
- // Parse the arguments
1908
- var parsed = parse(command, args, options);
1909
- // Spawn the child process
1910
- var result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
1911
- // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
1912
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1913
- return result;
1914
- }
1915
- crossSpawn6_0_5.exports = spawn;
1916
- crossSpawn6_0_5.exports.spawn = spawn;
1917
- crossSpawn6_0_5.exports.sync = spawnSync;
1918
- crossSpawn6_0_5.exports._parse = parse;
1919
- crossSpawn6_0_5.exports._enoent = enoent;
1920
- return crossSpawn6_0_5.exports;
622
+
623
+ return null;
1921
624
  }
1922
625
 
1923
- var hasRequiredSrc;
1924
- function requireSrc() {
1925
- if (hasRequiredSrc) return src$1.exports;
1926
- hasRequiredSrc = 1;
1927
- var path = require$$0$1;
1928
- var cp = require$$0$2;
1929
- var spawn_ = requireCrossSpawn6_0_5();
1930
- var NODES = [
1931
- 'node',
1932
- 'node.exe',
1933
- 'node.cmd'
1934
- ];
1935
- function parse(command, args, options) {
1936
- if (NODES.indexOf(path.basename(command).toLowerCase()) >= 0) {
1937
- var env = options ? options.env || process.env : process.env;
1938
- command = env.NODE || env.npm_node_execpath;
1939
- }
1940
- return spawn_._parse(command, args, options);
626
+ function verifyENOENTSync(status, parsed) {
627
+ if (isWin && status === 1 && !parsed.file) {
628
+ return notFoundError(parsed.original, 'spawnSync');
1941
629
  }
1942
- var enoent = spawn_._enoent;
1943
- function spawn(command, args, options) {
1944
- var parsed = parse(command, args, options);
1945
- var spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
1946
- enoent.hookChildProcess(spawned, parsed);
1947
- return spawned;
1948
- }
1949
- function spawnSync(command, args, options) {
1950
- var parsed = parse(command, args, options);
1951
- var result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
1952
- result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
1953
- return result;
1954
- }
1955
- src$1.exports = spawn;
1956
- src$1.exports.spawn = spawn;
1957
- src$1.exports.sync = spawnSync;
1958
- src$1.exports._parse = parse;
1959
- src$1.exports._enoent = enoent;
1960
- return src$1.exports;
630
+
631
+ return null;
1961
632
  }
1962
633
 
1963
- var srcExports = requireSrc();
1964
- var index = /*@__PURE__*/ getDefaultExportFromCjs(srcExports);
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;
1965
672
 
1966
- module.exports = index;
673
+ exports._enoent = _enoent;
674
+ exports._parse = _parse;
675
+ exports["default"] = crossSpawn.exports;
676
+ exports.spawn = spawn_1;
677
+ exports.sync = sync;