cross-spawn-cb 1.5.5 → 1.5.7

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