cross-spawn-cb 2.4.13 → 2.5.0

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