cross-spawn-cb 1.5.6 → 1.5.8

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,32 +1,32 @@
1
1
  // BEGIN SHIMS
2
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;
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
14
  }
15
15
 
16
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
- });
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
+ }));
28
24
  }
29
- return target;
25
+ ownKeys.forEach(function (key) {
26
+ _define_property(target, key, source[key]);
27
+ });
28
+ }
29
+ return target;
30
30
  }
31
31
  // END SHIMS
32
32
  'use strict';
@@ -40,10 +40,27 @@ function getDefaultExportFromCjs(x) {
40
40
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
41
41
  }
42
42
 
43
- var nodeCrossSpawn = {
43
+ var crossSpawn6_0_5 = {
44
44
  exports: {}
45
45
  };
46
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
+
47
64
  var windows;
48
65
  var hasRequiredWindows;
49
66
  function requireWindows() {
@@ -61,7 +78,7 @@ function requireWindows() {
61
78
  if (pathext.indexOf('') !== -1) {
62
79
  return true;
63
80
  }
64
- for (var i = 0; i < pathext.length; i++) {
81
+ for(var i = 0; i < pathext.length; i++){
65
82
  var p = pathext[i].toLowerCase();
66
83
  if (p && path.substr(-p.length).toLowerCase() === p) {
67
84
  return true;
@@ -76,7 +93,7 @@ function requireWindows() {
76
93
  return checkPathExt(path, options);
77
94
  }
78
95
  function isexe(path, options, cb) {
79
- fs.stat(path, function (er, stat) {
96
+ fs.stat(path, function(er, stat) {
80
97
  cb(er, er ? false : checkStat(stat, path, options));
81
98
  });
82
99
  }
@@ -95,7 +112,7 @@ function requireMode() {
95
112
  isexe.sync = sync;
96
113
  var fs = require$$0;
97
114
  function isexe(path, options, cb) {
98
- fs.stat(path, function (er, stat) {
115
+ fs.stat(path, function(er, stat) {
99
116
  cb(er, er ? false : checkStat(stat, options));
100
117
  });
101
118
  }
@@ -143,8 +160,8 @@ function requireIsexe() {
143
160
  if (typeof Promise !== 'function') {
144
161
  throw new TypeError('callback not provided');
145
162
  }
146
- return new Promise(function (resolve, reject) {
147
- isexe(path, options || {}, function (er, is) {
163
+ return new Promise(function(resolve, reject) {
164
+ isexe(path, options || {}, function(er, is) {
148
165
  if (er) {
149
166
  reject(er);
150
167
  } else {
@@ -153,7 +170,7 @@ function requireIsexe() {
153
170
  });
154
171
  });
155
172
  }
156
- core(path, options || {}, function (er, is) {
173
+ core(path, options || {}, function(er, is) {
157
174
  // ignore EACCES because that just means we aren't allowed to run it
158
175
  if (er) {
159
176
  if (er.code === 'EACCES' || options && options.ignoreErrors) {
@@ -179,159 +196,137 @@ function requireIsexe() {
179
196
  return isexe_1;
180
197
  }
181
198
 
182
- function _array_like_to_array$1(arr, len) {
183
- if (len == null || len > arr.length) len = arr.length;
184
- for (var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
185
- return arr2;
186
- }
187
- function _array_without_holes(arr) {
188
- if (Array.isArray(arr)) return _array_like_to_array$1(arr);
189
- }
190
- function _iterable_to_array(iter) {
191
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
192
- }
193
- function _non_iterable_spread() {
194
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
195
- }
196
- function _to_consumable_array(arr) {
197
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array$1(arr) || _non_iterable_spread();
198
- }
199
- function _unsupported_iterable_to_array$1(o, minLen) {
200
- if (!o) return;
201
- if (typeof o === "string") return _array_like_to_array$1(o, minLen);
202
- var n = Object.prototype.toString.call(o).slice(8, -1);
203
- if (n === "Object" && o.constructor) n = o.constructor.name;
204
- if (n === "Map" || n === "Set") return Array.from(n);
205
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
206
- }
207
199
  var which_1;
208
200
  var hasRequiredWhich;
209
201
  function requireWhich() {
210
202
  if (hasRequiredWhich) return which_1;
211
203
  hasRequiredWhich = 1;
204
+ which_1 = which;
205
+ which.sync = whichSync;
212
206
  var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
213
207
  var path = require$$0$1;
214
208
  var COLON = isWindows ? ';' : ':';
215
209
  var isexe = requireIsexe();
216
- var getNotFoundError = function (cmd) {
217
- return _object_spread(new Error("not found: ".concat(cmd)), {
218
- code: 'ENOENT'
219
- });
220
- };
221
- var getPathInfo = function (cmd, opt) {
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) {
222
216
  var colon = opt.colon || COLON;
223
- // If it has a slash, then we don't bother searching the pathenv.
224
- // just check the file itself, and that's it.
225
- var pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [
226
- ''
227
- ] : // windows always checks the cwd first
228
- _to_consumable_array(isWindows ? [
229
- process.cwd()
230
- ] : []).concat(_to_consumable_array((opt.path || process.env.PATH || /* istanbul ignore next: very unusual */ '').split(colon)));
231
- var pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' : '';
232
- var pathExt = isWindows ? pathExtExe.split(colon) : [
217
+ var pathEnv = opt.path || process.env.PATH || '';
218
+ var pathExt = [
233
219
  ''
234
220
  ];
221
+ pathEnv = pathEnv.split(colon);
222
+ var pathExtExe = '';
235
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.
236
229
  if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('');
237
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
+ ];
238
236
  return {
239
- pathEnv: pathEnv,
240
- pathExt: pathExt,
241
- pathExtExe: pathExtExe
237
+ env: pathEnv,
238
+ ext: pathExt,
239
+ extExe: pathExtExe
242
240
  };
243
- };
244
- var which = function (cmd, opt, cb) {
241
+ }
242
+ function which(cmd, opt, cb) {
245
243
  if (typeof opt === 'function') {
246
244
  cb = opt;
247
245
  opt = {};
248
246
  }
249
- if (!opt) opt = {};
250
- 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;
251
251
  var found = [];
252
- var step = function (i) {
253
- return new Promise(function (resolve, reject) {
254
- if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
255
- var ppRaw = pathEnv[i];
256
- var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
257
- var pCmd = path.join(pathPart, cmd);
258
- var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
259
- resolve(subStep(p, i, 0));
260
- });
261
- };
262
- var subStep = function (p, i, ii) {
263
- return new Promise(function (resolve, reject) {
264
- if (ii === pathExt.length) return resolve(step(i + 1));
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);
265
265
  var ext = pathExt[ii];
266
266
  isexe(p + ext, {
267
267
  pathExt: pathExtExe
268
- }, function (er, is) {
268
+ }, function(er, is) {
269
269
  if (!er && is) {
270
270
  if (opt.all) found.push(p + ext);
271
- else return resolve(p + ext);
271
+ else return cb(null, p + ext);
272
272
  }
273
- return resolve(subStep(p, i, ii + 1));
273
+ return E(ii + 1, ll);
274
274
  });
275
- });
276
- };
277
- return cb ? step(0).then(function (res) {
278
- return cb(null, res);
279
- }, cb) : step(0);
280
- };
281
- var whichSync = function (cmd, opt) {
275
+ })(0, pathExt.length);
276
+ })(0, pathEnv.length);
277
+ }
278
+ function whichSync(cmd, opt) {
282
279
  opt = opt || {};
283
- 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;
284
284
  var found = [];
285
- for (var i = 0; i < pathEnv.length; i++) {
286
- var ppRaw = pathEnv[i];
287
- var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
288
- var pCmd = path.join(pathPart, cmd);
289
- var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
290
- for (var j = 0; j < pathExt.length; j++) {
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++){
291
293
  var cur = p + pathExt[j];
294
+ var is;
292
295
  try {
293
- var is = isexe.sync(cur, {
296
+ is = isexe.sync(cur, {
294
297
  pathExt: pathExtExe
295
298
  });
296
299
  if (is) {
297
300
  if (opt.all) found.push(cur);
298
301
  else return cur;
299
302
  }
300
- } catch (ex) { }
303
+ } catch (ex) {}
301
304
  }
302
305
  }
303
306
  if (opt.all && found.length) return found;
304
307
  if (opt.nothrow) return null;
305
308
  throw getNotFoundError(cmd);
306
- };
307
- which_1 = which;
308
- which.sync = whichSync;
309
+ }
309
310
  return which_1;
310
311
  }
311
312
 
312
- var pathKey = {
313
- exports: {}
314
- };
315
-
313
+ var pathKey;
316
314
  var hasRequiredPathKey;
317
315
  function requirePathKey() {
318
- if (hasRequiredPathKey) return pathKey.exports;
316
+ if (hasRequiredPathKey) return pathKey;
319
317
  hasRequiredPathKey = 1;
320
- var pathKey$1 = function () {
321
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
322
- var environment = options.env || process.env;
323
- var platform = options.platform || process.platform;
318
+ pathKey = function(opts) {
319
+ opts = opts || {};
320
+ var env = opts.env || process.env;
321
+ var platform = opts.platform || process.platform;
324
322
  if (platform !== 'win32') {
325
323
  return 'PATH';
326
324
  }
327
- return Object.keys(environment).reverse().find(function (key) {
328
- return key.toUpperCase() === 'PATH';
325
+ return Object.keys(env).find(function(x) {
326
+ return x.toUpperCase() === 'PATH';
329
327
  }) || 'Path';
330
328
  };
331
- pathKey.exports = pathKey$1;
332
- // TODO: Remove this for the next major release
333
- pathKey.exports.default = pathKey$1;
334
- return pathKey.exports;
329
+ return pathKey;
335
330
  }
336
331
 
337
332
  var resolveCommand_1;
@@ -341,36 +336,27 @@ function requireResolveCommand() {
341
336
  hasRequiredResolveCommand = 1;
342
337
  var path = require$$0$1;
343
338
  var which = requireWhich();
344
- var getPathKey = requirePathKey();
339
+ var pathKey = requirePathKey()();
345
340
  function resolveCommandAttempt(parsed, withoutPathExt) {
346
- var env = parsed.options.env || process.env;
347
341
  var cwd = process.cwd();
348
342
  var hasCustomCwd = parsed.options.cwd != null;
349
- // Worker threads do not have process.chdir()
350
- var shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
351
343
  // If a custom `cwd` was specified, we need to change the process cwd
352
344
  // because `which` will do stat calls but does not support a custom cwd
353
- if (shouldSwitchCwd) {
345
+ if (hasCustomCwd) {
354
346
  try {
355
347
  process.chdir(parsed.options.cwd);
356
348
  } catch (err) {
357
- /* Empty */
358
- }
349
+ /* Empty */ }
359
350
  }
360
351
  var resolved;
361
352
  try {
362
353
  resolved = which.sync(parsed.command, {
363
- path: env[getPathKey({
364
- env: env
365
- })],
354
+ path: (parsed.options.env || process.env)[pathKey],
366
355
  pathExt: withoutPathExt ? path.delimiter : undefined
367
356
  });
368
357
  } catch (e) {
369
- /* Empty */
370
- } finally {
371
- if (shouldSwitchCwd) {
372
- process.chdir(cwd);
373
- }
358
+ /* Empty */ } finally{
359
+ process.chdir(cwd);
374
360
  }
375
361
  // If we successfully resolved, ensure that an absolute path is returned
376
362
  // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
@@ -403,15 +389,13 @@ function require_escape() {
403
389
  // Convert to string
404
390
  arg = "".concat(arg);
405
391
  // Algorithm below is based on https://qntm.org/cmd
406
- // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
407
- // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
408
392
  // Sequence of backslashes followed by a double quote:
409
393
  // double up all the backslashes and escape the double quote
410
- arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
394
+ arg = arg.replace(/(\\*)"/g, '$1$1\\"');
411
395
  // Sequence of backslashes followed by the end of the string
412
396
  // (which will become a double quote later):
413
397
  // double up all the backslashes
414
- arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
398
+ arg = arg.replace(/(\\*)$/, '$1$1');
415
399
  // All other backslashes occur literally
416
400
  // Quote the whole thing:
417
401
  arg = '"'.concat(arg, '"');
@@ -433,74 +417,25 @@ var hasRequiredShebangRegex;
433
417
  function requireShebangRegex() {
434
418
  if (hasRequiredShebangRegex) return shebangRegex;
435
419
  hasRequiredShebangRegex = 1;
436
- shebangRegex = /^#!(.*)/;
420
+ shebangRegex = /^#!.*/;
437
421
  return shebangRegex;
438
422
  }
439
423
 
440
- function _array_like_to_array(arr, len) {
441
- if (len == null || len > arr.length) len = arr.length;
442
- for (var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
443
- return arr2;
444
- }
445
- function _array_with_holes(arr) {
446
- if (Array.isArray(arr)) return arr;
447
- }
448
- function _iterable_to_array_limit(arr, i) {
449
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
450
- if (_i == null) return;
451
- var _arr = [];
452
- var _n = true;
453
- var _d = false;
454
- var _s, _e;
455
- try {
456
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
457
- _arr.push(_s.value);
458
- if (i && _arr.length === i) break;
459
- }
460
- } catch (err) {
461
- _d = true;
462
- _e = err;
463
- } finally {
464
- try {
465
- if (!_n && _i["return"] != null) _i["return"]();
466
- } finally {
467
- if (_d) throw _e;
468
- }
469
- }
470
- return _arr;
471
- }
472
- function _non_iterable_rest() {
473
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
474
- }
475
- function _sliced_to_array(arr, i) {
476
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
477
- }
478
- function _unsupported_iterable_to_array(o, minLen) {
479
- if (!o) return;
480
- if (typeof o === "string") return _array_like_to_array(o, minLen);
481
- var n = Object.prototype.toString.call(o).slice(8, -1);
482
- if (n === "Object" && o.constructor) n = o.constructor.name;
483
- if (n === "Map" || n === "Set") return Array.from(n);
484
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
485
- }
486
424
  var shebangCommand;
487
425
  var hasRequiredShebangCommand;
488
426
  function requireShebangCommand() {
489
427
  if (hasRequiredShebangCommand) return shebangCommand;
490
428
  hasRequiredShebangCommand = 1;
491
429
  var shebangRegex = requireShebangRegex();
492
- shebangCommand = function () {
493
- var string = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
494
- var match = string.match(shebangRegex);
430
+ shebangCommand = function shebangCommand(str) {
431
+ var match = str.match(shebangRegex);
495
432
  if (!match) {
496
433
  return null;
497
434
  }
498
- var _match__replace_split = _sliced_to_array(match[0].replace(/#! ?/, '').split(' '), 2), path = _match__replace_split[0], argument = _match__replace_split[1];
499
- var binary = path.split('/').pop();
500
- if (binary === 'env') {
501
- return argument;
502
- }
503
- return argument ? "".concat(binary, " ").concat(argument) : binary;
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 : '');
504
439
  };
505
440
  return shebangCommand;
506
441
  }
@@ -515,13 +450,21 @@ function requireReadShebang() {
515
450
  function readShebang(command) {
516
451
  // Read the first 150 bytes from the file
517
452
  var size = 150;
518
- 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
+ }
519
462
  var fd;
520
463
  try {
521
464
  fd = fs.openSync(command, 'r');
522
465
  fs.readSync(fd, buffer, 0, size, 0);
523
466
  fs.closeSync(fd);
524
- } catch (e) { }
467
+ } catch (e) {}
525
468
  // Attempt to extract shebang (null is returned if not a shebang)
526
469
  return shebangCommand(buffer.toString());
527
470
  }
@@ -529,18 +472,1285 @@ function requireReadShebang() {
529
472
  return readShebang_1;
530
473
  }
531
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
+
532
1736
  var parse_1;
533
1737
  var hasRequiredParse;
534
1738
  function requireParse() {
535
1739
  if (hasRequiredParse) return parse_1;
536
1740
  hasRequiredParse = 1;
537
1741
  var path = require$$0$1;
1742
+ var niceTry = requireSrc();
538
1743
  var resolveCommand = requireResolveCommand();
539
1744
  var escape = require_escape();
540
1745
  var readShebang = requireReadShebang();
1746
+ var semver = requireSemver();
541
1747
  var isWin = process.platform === 'win32';
542
1748
  var isExecutableRegExp = /\.(?:com|exe)$/i;
543
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;
544
1754
  function detectShebang(parsed) {
545
1755
  parsed.file = resolveCommand(parsed);
546
1756
  var shebang = parsed.file && readShebang(parsed.file);
@@ -572,7 +1782,7 @@ function requireParse() {
572
1782
  parsed.command = path.normalize(parsed.command);
573
1783
  // Escape command & arguments
574
1784
  parsed.command = escape.command(parsed.command);
575
- parsed.args = parsed.args.map(function (arg) {
1785
+ parsed.args = parsed.args.map(function(arg) {
576
1786
  return escape.argument(arg, needsDoubleEscapeMetaChars);
577
1787
  });
578
1788
  var shellCommand = [
@@ -589,6 +1799,40 @@ function requireParse() {
589
1799
  }
590
1800
  return parsed;
591
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
+ }
592
1836
  function parse(command, args, options) {
593
1837
  // Normalize arguments, similar to nodejs
594
1838
  if (args && !Array.isArray(args)) {
@@ -609,7 +1853,7 @@ function requireParse() {
609
1853
  }
610
1854
  };
611
1855
  // Delegate further parsing to shell or non-shell
612
- return options.shell ? parsed : parseNonShell(parsed);
1856
+ return options.shell ? parseShell(parsed) : parseNonShell(parsed);
613
1857
  }
614
1858
  parse_1 = parse;
615
1859
  return parse_1;
@@ -635,7 +1879,7 @@ function requireEnoent() {
635
1879
  return;
636
1880
  }
637
1881
  var originalEmit = cp.emit;
638
- cp.emit = function (name, arg1) {
1882
+ cp.emit = function(name, arg1) {
639
1883
  // If emitting "exit" event and exit code is 1, we need to check if
640
1884
  // the command exists and emit an "error" instead
641
1885
  // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
@@ -669,10 +1913,10 @@ function requireEnoent() {
669
1913
  return enoent;
670
1914
  }
671
1915
 
672
- var hasRequiredNodeCrossSpawn;
673
- function requireNodeCrossSpawn() {
674
- if (hasRequiredNodeCrossSpawn) return nodeCrossSpawn.exports;
675
- 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;
676
1920
  var cp = require$$0$2;
677
1921
  var parse = requireParse();
678
1922
  var enoent = requireEnoent();
@@ -695,15 +1939,15 @@ function requireNodeCrossSpawn() {
695
1939
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
696
1940
  return result;
697
1941
  }
698
- nodeCrossSpawn.exports = spawn;
699
- nodeCrossSpawn.exports.spawn = spawn;
700
- nodeCrossSpawn.exports.sync = spawnSync;
701
- nodeCrossSpawn.exports._parse = parse;
702
- nodeCrossSpawn.exports._enoent = enoent;
703
- return nodeCrossSpawn.exports;
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;
704
1948
  }
705
1949
 
706
- var nodeCrossSpawnExports = requireNodeCrossSpawn();
707
- var index = /*@__PURE__*/ getDefaultExportFromCjs(nodeCrossSpawnExports);
1950
+ var crossSpawn6_0_5Exports = requireCrossSpawn6_0_5();
1951
+ var index = /*@__PURE__*/ getDefaultExportFromCjs(crossSpawn6_0_5Exports);
708
1952
 
709
1953
  module.exports = index;