fsevents 1.2.3 → 1.2.10
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.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/.travis.yml +2 -3
- package/fsevents.cc +14 -26
- package/node_modules/abbrev/package.json +13 -14
- package/node_modules/ansi-regex/package.json +13 -14
- package/node_modules/aproba/package.json +13 -14
- package/node_modules/are-we-there-yet/CHANGES.md +6 -0
- package/node_modules/are-we-there-yet/package.json +19 -20
- package/node_modules/are-we-there-yet/tracker-stream.js +1 -0
- package/node_modules/balanced-match/package.json +13 -14
- package/node_modules/brace-expansion/package.json +13 -14
- package/node_modules/chownr/chownr.js +113 -40
- package/node_modules/chownr/package.json +22 -20
- package/node_modules/code-point-at/package.json +13 -14
- package/node_modules/concat-map/package.json +8 -9
- package/node_modules/console-control-strings/package.json +14 -14
- package/node_modules/core-util-is/package.json +13 -14
- package/node_modules/debug/CHANGELOG.md +34 -1
- package/node_modules/debug/README.md +188 -63
- package/node_modules/debug/dist/debug.js +886 -0
- package/node_modules/debug/package.json +34 -33
- package/node_modules/debug/src/browser.js +77 -82
- package/node_modules/debug/src/common.js +249 -0
- package/node_modules/debug/src/index.js +5 -3
- package/node_modules/debug/src/node.js +72 -146
- package/node_modules/deep-extend/CHANGELOG.md +28 -3
- package/node_modules/deep-extend/LICENSE +1 -1
- package/node_modules/deep-extend/README.md +2 -1
- package/node_modules/deep-extend/lib/deep-extend.js +11 -5
- package/node_modules/deep-extend/package.json +26 -28
- package/node_modules/delegates/package.json +13 -14
- package/node_modules/detect-libc/package.json +13 -14
- package/node_modules/fs-minipass/index.js +2 -1
- package/node_modules/fs-minipass/package.json +24 -22
- package/node_modules/fs.realpath/package.json +13 -14
- package/node_modules/gauge/package.json +13 -14
- package/node_modules/glob/LICENSE +6 -0
- package/node_modules/glob/README.md +8 -1
- package/node_modules/glob/package.json +21 -19
- package/node_modules/has-unicode/package.json +13 -14
- package/node_modules/iconv-lite/Changelog.md +16 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +2 -2
- package/node_modules/iconv-lite/encodings/sbcs-data.js +5 -0
- package/node_modules/iconv-lite/lib/extend-node.js +1 -1
- package/node_modules/iconv-lite/lib/index.d.ts +2 -2
- package/node_modules/iconv-lite/package.json +19 -20
- package/node_modules/ignore-walk/README.md +1 -1
- package/node_modules/ignore-walk/index.js +9 -5
- package/node_modules/ignore-walk/package.json +22 -20
- package/node_modules/inflight/package.json +13 -14
- package/node_modules/inherits/inherits.js +2 -0
- package/node_modules/inherits/inherits_browser.js +18 -14
- package/node_modules/inherits/package.json +20 -20
- package/node_modules/ini/package.json +13 -14
- package/node_modules/is-fullwidth-code-point/package.json +13 -14
- package/node_modules/isarray/package.json +13 -14
- package/node_modules/minimatch/package.json +14 -14
- package/node_modules/minimist/package.json +8 -9
- package/node_modules/minipass/LICENSE +15 -0
- package/node_modules/minipass/README.md +567 -7
- package/node_modules/minipass/index.js +255 -22
- package/node_modules/minipass/package.json +26 -22
- package/node_modules/minizlib/README.md +36 -27
- package/node_modules/minizlib/constants.js +73 -4
- package/node_modules/minizlib/index.js +188 -232
- package/node_modules/minizlib/package.json +19 -20
- package/node_modules/mkdirp/package.json +14 -14
- package/node_modules/ms/index.js +29 -19
- package/node_modules/ms/package.json +22 -23
- package/node_modules/ms/readme.md +18 -9
- package/node_modules/needle/README.md +3 -3
- package/node_modules/needle/examples/multipart-stream.js +1 -1
- package/node_modules/needle/lib/auth.js +1 -1
- package/node_modules/needle/lib/cookies.js +12 -10
- package/node_modules/needle/lib/multipart.js +1 -1
- package/node_modules/needle/lib/needle.js +20 -6
- package/node_modules/needle/package.json +26 -27
- package/node_modules/needle/test/basic_auth_spec.js +1 -1
- package/node_modules/needle/test/cookies_spec.js +2 -2
- package/node_modules/needle/test/errors_spec.js +4 -4
- package/node_modules/needle/test/headers_spec.js +1 -1
- package/node_modules/needle/test/long_string_spec.js +1 -1
- package/node_modules/needle/test/output_spec.js +1 -1
- package/node_modules/needle/test/post_data_spec.js +20 -20
- package/node_modules/needle/test/proxy_spec.js +1 -1
- package/node_modules/needle/test/url_spec.js +11 -3
- package/node_modules/needle/test/utils/test.js +1 -1
- package/node_modules/node-pre-gyp/CHANGELOG.md +34 -3
- package/node_modules/node-pre-gyp/README.md +53 -21
- package/node_modules/node-pre-gyp/appveyor.yml +2 -9
- package/node_modules/node-pre-gyp/contributing.md +2 -2
- package/node_modules/node-pre-gyp/lib/build.js +1 -1
- package/node_modules/node-pre-gyp/lib/install.js +46 -12
- package/node_modules/node-pre-gyp/lib/node-pre-gyp.js +1 -1
- package/node_modules/node-pre-gyp/lib/package.js +5 -2
- package/node_modules/node-pre-gyp/lib/pre-binding.js +5 -5
- package/node_modules/node-pre-gyp/lib/rebuild.js +1 -1
- package/node_modules/node-pre-gyp/lib/reinstall.js +1 -1
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +148 -0
- package/node_modules/node-pre-gyp/lib/util/handle_gyp_opts.js +5 -2
- package/node_modules/node-pre-gyp/lib/util/napi.js +70 -22
- package/node_modules/node-pre-gyp/lib/util/versioning.js +7 -6
- package/node_modules/node-pre-gyp/package.json +16 -20
- package/node_modules/nopt/package.json +13 -14
- package/node_modules/npm-bundled/LICENSE +15 -0
- package/node_modules/npm-bundled/README.md +2 -0
- package/node_modules/npm-bundled/index.js +29 -7
- package/node_modules/npm-bundled/package.json +21 -19
- package/node_modules/npm-normalize-package-bin/.github/settings.yml +2 -0
- package/node_modules/npm-normalize-package-bin/.npmignore +24 -0
- package/node_modules/npm-normalize-package-bin/LICENSE +15 -0
- package/node_modules/npm-normalize-package-bin/README.md +14 -0
- package/node_modules/npm-normalize-package-bin/index.js +60 -0
- package/node_modules/npm-normalize-package-bin/package-lock.json +3529 -0
- package/node_modules/npm-normalize-package-bin/package.json +57 -0
- package/node_modules/npm-normalize-package-bin/test/array.js +37 -0
- package/node_modules/npm-normalize-package-bin/test/nobin.js +35 -0
- package/node_modules/npm-normalize-package-bin/test/object.js +141 -0
- package/node_modules/npm-normalize-package-bin/test/string.js +37 -0
- package/node_modules/npm-packlist/index.js +90 -21
- package/node_modules/npm-packlist/package.json +27 -21
- package/node_modules/npmlog/package.json +13 -14
- package/node_modules/number-is-nan/package.json +13 -14
- package/node_modules/object-assign/package.json +13 -14
- package/node_modules/once/package.json +14 -14
- package/node_modules/os-homedir/package.json +13 -14
- package/node_modules/os-tmpdir/package.json +13 -14
- package/node_modules/osenv/package.json +13 -14
- package/node_modules/path-is-absolute/package.json +13 -14
- package/node_modules/process-nextick-args/index.js +2 -1
- package/node_modules/process-nextick-args/package.json +17 -18
- package/node_modules/rc/node_modules/minimist/package.json +13 -14
- package/node_modules/rc/package.json +18 -19
- package/node_modules/readable-stream/package.json +13 -14
- package/node_modules/rimraf/package.json +22 -20
- package/node_modules/rimraf/rimraf.js +9 -1
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/package.json +23 -21
- package/node_modules/safer-buffer/package.json +13 -14
- package/node_modules/sax/package.json +13 -14
- package/node_modules/semver/CHANGELOG.md +39 -0
- package/node_modules/semver/README.md +43 -19
- package/node_modules/semver/bin/semver +92 -75
- package/node_modules/semver/package.json +25 -20
- package/node_modules/semver/semver.js +922 -763
- package/node_modules/set-blocking/package.json +13 -14
- package/node_modules/signal-exit/package.json +13 -14
- package/node_modules/string-width/package.json +14 -14
- package/node_modules/string_decoder/package.json +13 -14
- package/node_modules/strip-ansi/package.json +14 -14
- package/node_modules/strip-json-comments/package.json +13 -14
- package/node_modules/tar/README.md +7 -2
- package/node_modules/tar/lib/header.js +20 -4
- package/node_modules/tar/lib/large-numbers.js +32 -27
- package/node_modules/tar/lib/mkdir.js +2 -2
- package/node_modules/tar/lib/mode-fix.js +14 -0
- package/node_modules/tar/lib/pack.js +1 -0
- package/node_modules/tar/lib/parse.js +7 -1
- package/node_modules/tar/lib/read-entry.js +4 -0
- package/node_modules/tar/lib/unpack.js +67 -6
- package/node_modules/tar/lib/write-entry.js +25 -6
- package/node_modules/tar/package.json +33 -30
- package/node_modules/util-deprecate/package.json +13 -14
- package/node_modules/wide-align/package.json +19 -20
- package/node_modules/wrappy/package.json +14 -14
- package/node_modules/yallist/iterator.js +5 -5
- package/node_modules/yallist/package.json +19 -19
- package/node_modules/yallist/yallist.js +52 -2
- package/package.json +6 -9
- package/src/async.cc +2 -2
- package/src/constants.cc +20 -20
- package/src/thread.cc +5 -6
- package/.npmignore +0 -1
- package/build/.target.mk +0 -53
- package/build/Makefile +0 -352
- package/build/Release/.deps/Release/.node.d +0 -1
- package/build/Release/.deps/Release/fse.node.d +0 -1
- package/build/Release/.deps/Release/obj.target/action_after_build.stamp.d +0 -1
- package/build/Release/.deps/Release/obj.target/fse/fsevents.o.d +0 -65
- package/build/Release/.deps/Users/eshanker/Code/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node.d +0 -1
- package/build/Release/.node +0 -0
- package/build/Release/fse.node +0 -0
- package/build/Release/obj.target/action_after_build.stamp +0 -0
- package/build/Release/obj.target/fse/fsevents.o +0 -0
- package/build/action_after_build.target.mk +0 -32
- package/build/binding.Makefile +0 -6
- package/build/fse.target.mk +0 -179
- package/build/gyp-mac-tool +0 -611
- package/build/stage/v1.1.2/fse-v1.1.2-node-v48-darwin-x64.tar.gz +0 -0
- package/lib/binding/Release/node-v11-darwin-x64/fse.node +0 -0
- package/lib/binding/Release/node-v46-darwin-x64/fse.node +0 -0
- package/lib/binding/Release/node-v47-darwin-x64/fse.node +0 -0
- package/lib/binding/Release/node-v48-darwin-x64/fse.node +0 -0
- package/lib/binding/Release/node-v57-darwin-x64/fse.node +0 -0
- package/node_modules/are-we-there-yet/CHANGES.md~ +0 -27
- package/node_modules/debug/.coveralls.yml +0 -1
- package/node_modules/debug/.eslintrc +0 -11
- package/node_modules/debug/.npmignore +0 -9
- package/node_modules/debug/.travis.yml +0 -14
- package/node_modules/debug/Makefile +0 -50
- package/node_modules/debug/component.json +0 -19
- package/node_modules/debug/karma.conf.js +0 -70
- package/node_modules/debug/src/debug.js +0 -202
- package/node_modules/debug/src/inspector-log.js +0 -15
- package/node_modules/iconv-lite/.travis.yml +0 -23
- package/node_modules/rc/.npmignore +0 -3
- package/node_modules/safe-buffer/.travis.yml +0 -7
- package/node_modules/safe-buffer/test.js +0 -101
- package/src/locking.cc +0 -27
@@ -1,33 +1,35 @@
|
|
1
|
-
exports = module.exports = SemVer
|
2
|
-
|
3
|
-
|
4
|
-
/*
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
1
|
+
exports = module.exports = SemVer
|
2
|
+
|
3
|
+
var debug
|
4
|
+
/* istanbul ignore next */
|
5
|
+
if (typeof process === 'object' &&
|
6
|
+
process.env &&
|
7
|
+
process.env.NODE_DEBUG &&
|
8
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
9
|
+
debug = function () {
|
10
|
+
var args = Array.prototype.slice.call(arguments, 0)
|
11
|
+
args.unshift('SEMVER')
|
12
|
+
console.log.apply(console, args)
|
13
|
+
}
|
14
|
+
} else {
|
15
|
+
debug = function () {}
|
16
|
+
}
|
16
17
|
|
17
18
|
// Note: this is the semver.org version of the spec that it implements
|
18
19
|
// Not necessarily the package version of this code.
|
19
|
-
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
20
|
+
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
20
21
|
|
21
|
-
var MAX_LENGTH = 256
|
22
|
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
22
|
+
var MAX_LENGTH = 256
|
23
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
24
|
+
/* istanbul ignore next */ 9007199254740991
|
23
25
|
|
24
26
|
// Max safe segment length for coercion.
|
25
|
-
var MAX_SAFE_COMPONENT_LENGTH = 16
|
27
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16
|
26
28
|
|
27
29
|
// The actual regexps go on exports.re
|
28
|
-
var re = exports.re = []
|
29
|
-
var src = exports.src = []
|
30
|
-
var R = 0
|
30
|
+
var re = exports.re = []
|
31
|
+
var src = exports.src = []
|
32
|
+
var R = 0
|
31
33
|
|
32
34
|
// The following Regular Expressions can be used for tokenizing,
|
33
35
|
// validating, and parsing SemVer version strings.
|
@@ -35,71 +37,67 @@ var R = 0;
|
|
35
37
|
// ## Numeric Identifier
|
36
38
|
// A single `0`, or a non-zero digit followed by zero or more digits.
|
37
39
|
|
38
|
-
var NUMERICIDENTIFIER = R
|
39
|
-
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
40
|
-
var NUMERICIDENTIFIERLOOSE = R
|
41
|
-
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
42
|
-
|
40
|
+
var NUMERICIDENTIFIER = R++
|
41
|
+
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
42
|
+
var NUMERICIDENTIFIERLOOSE = R++
|
43
|
+
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
43
44
|
|
44
45
|
// ## Non-numeric Identifier
|
45
46
|
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
46
47
|
// more letters, digits, or hyphens.
|
47
48
|
|
48
|
-
var NONNUMERICIDENTIFIER = R
|
49
|
-
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
50
|
-
|
49
|
+
var NONNUMERICIDENTIFIER = R++
|
50
|
+
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
51
51
|
|
52
52
|
// ## Main Version
|
53
53
|
// Three dot-separated numeric identifiers.
|
54
54
|
|
55
|
-
var MAINVERSION = R
|
55
|
+
var MAINVERSION = R++
|
56
56
|
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
57
57
|
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
58
|
-
'(' + src[NUMERICIDENTIFIER] + ')'
|
58
|
+
'(' + src[NUMERICIDENTIFIER] + ')'
|
59
59
|
|
60
|
-
var MAINVERSIONLOOSE = R
|
60
|
+
var MAINVERSIONLOOSE = R++
|
61
61
|
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
62
62
|
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
63
|
-
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
63
|
+
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
64
64
|
|
65
65
|
// ## Pre-release Version Identifier
|
66
66
|
// A numeric identifier, or a non-numeric identifier.
|
67
67
|
|
68
|
-
var PRERELEASEIDENTIFIER = R
|
68
|
+
var PRERELEASEIDENTIFIER = R++
|
69
69
|
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
|
70
|
-
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
70
|
+
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
71
71
|
|
72
|
-
var PRERELEASEIDENTIFIERLOOSE = R
|
72
|
+
var PRERELEASEIDENTIFIERLOOSE = R++
|
73
73
|
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
|
74
|
-
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
75
|
-
|
74
|
+
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
76
75
|
|
77
76
|
// ## Pre-release Version
|
78
77
|
// Hyphen, followed by one or more dot-separated pre-release version
|
79
78
|
// identifiers.
|
80
79
|
|
81
|
-
var PRERELEASE = R
|
80
|
+
var PRERELEASE = R++
|
82
81
|
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
|
83
|
-
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
82
|
+
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
84
83
|
|
85
|
-
var PRERELEASELOOSE = R
|
84
|
+
var PRERELEASELOOSE = R++
|
86
85
|
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
|
87
|
-
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
86
|
+
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
88
87
|
|
89
88
|
// ## Build Metadata Identifier
|
90
89
|
// Any combination of digits, letters, or hyphens.
|
91
90
|
|
92
|
-
var BUILDIDENTIFIER = R
|
93
|
-
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
91
|
+
var BUILDIDENTIFIER = R++
|
92
|
+
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
94
93
|
|
95
94
|
// ## Build Metadata
|
96
95
|
// Plus sign, followed by one or more period-separated build metadata
|
97
96
|
// identifiers.
|
98
97
|
|
99
|
-
var BUILD = R
|
98
|
+
var BUILD = R++
|
100
99
|
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
101
|
-
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
102
|
-
|
100
|
+
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
103
101
|
|
104
102
|
// ## Full Version String
|
105
103
|
// A main version, followed optionally by a pre-release version and
|
@@ -110,783 +108,870 @@ src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
|
110
108
|
// capturing group, because it should not ever be used in version
|
111
109
|
// comparison.
|
112
110
|
|
113
|
-
var FULL = R
|
111
|
+
var FULL = R++
|
114
112
|
var FULLPLAIN = 'v?' + src[MAINVERSION] +
|
115
113
|
src[PRERELEASE] + '?' +
|
116
|
-
src[BUILD] + '?'
|
114
|
+
src[BUILD] + '?'
|
117
115
|
|
118
|
-
src[FULL] = '^' + FULLPLAIN + '$'
|
116
|
+
src[FULL] = '^' + FULLPLAIN + '$'
|
119
117
|
|
120
118
|
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
121
119
|
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
122
120
|
// common in the npm registry.
|
123
121
|
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
|
124
122
|
src[PRERELEASELOOSE] + '?' +
|
125
|
-
src[BUILD] + '?'
|
123
|
+
src[BUILD] + '?'
|
126
124
|
|
127
|
-
var LOOSE = R
|
128
|
-
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
125
|
+
var LOOSE = R++
|
126
|
+
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
129
127
|
|
130
|
-
var GTLT = R
|
131
|
-
src[GTLT] = '((?:<|>)?=?)'
|
128
|
+
var GTLT = R++
|
129
|
+
src[GTLT] = '((?:<|>)?=?)'
|
132
130
|
|
133
131
|
// Something like "2.*" or "1.2.x".
|
134
132
|
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
135
133
|
// Only the first item is strictly required.
|
136
|
-
var XRANGEIDENTIFIERLOOSE = R
|
137
|
-
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
138
|
-
var XRANGEIDENTIFIER = R
|
139
|
-
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
134
|
+
var XRANGEIDENTIFIERLOOSE = R++
|
135
|
+
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
136
|
+
var XRANGEIDENTIFIER = R++
|
137
|
+
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
140
138
|
|
141
|
-
var XRANGEPLAIN = R
|
139
|
+
var XRANGEPLAIN = R++
|
142
140
|
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
|
143
141
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
144
142
|
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
145
143
|
'(?:' + src[PRERELEASE] + ')?' +
|
146
144
|
src[BUILD] + '?' +
|
147
|
-
')?)?'
|
145
|
+
')?)?'
|
148
146
|
|
149
|
-
var XRANGEPLAINLOOSE = R
|
147
|
+
var XRANGEPLAINLOOSE = R++
|
150
148
|
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
151
149
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
152
150
|
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
153
151
|
'(?:' + src[PRERELEASELOOSE] + ')?' +
|
154
152
|
src[BUILD] + '?' +
|
155
|
-
')?)?'
|
153
|
+
')?)?'
|
156
154
|
|
157
|
-
var XRANGE = R
|
158
|
-
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
159
|
-
var XRANGELOOSE = R
|
160
|
-
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
155
|
+
var XRANGE = R++
|
156
|
+
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
157
|
+
var XRANGELOOSE = R++
|
158
|
+
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
161
159
|
|
162
160
|
// Coercion.
|
163
161
|
// Extract anything that could conceivably be a part of a valid semver
|
164
|
-
var COERCE = R
|
162
|
+
var COERCE = R++
|
165
163
|
src[COERCE] = '(?:^|[^\\d])' +
|
166
164
|
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
167
165
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
168
166
|
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
169
|
-
'(?:$|[^\\d])'
|
167
|
+
'(?:$|[^\\d])'
|
170
168
|
|
171
169
|
// Tilde ranges.
|
172
170
|
// Meaning is "reasonably at or greater than"
|
173
|
-
var LONETILDE = R
|
174
|
-
src[LONETILDE] = '(?:~>?)'
|
171
|
+
var LONETILDE = R++
|
172
|
+
src[LONETILDE] = '(?:~>?)'
|
175
173
|
|
176
|
-
var TILDETRIM = R
|
177
|
-
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
178
|
-
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
179
|
-
var tildeTrimReplace = '$1~'
|
174
|
+
var TILDETRIM = R++
|
175
|
+
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
176
|
+
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
177
|
+
var tildeTrimReplace = '$1~'
|
180
178
|
|
181
|
-
var TILDE = R
|
182
|
-
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
183
|
-
var TILDELOOSE = R
|
184
|
-
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
179
|
+
var TILDE = R++
|
180
|
+
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
181
|
+
var TILDELOOSE = R++
|
182
|
+
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
185
183
|
|
186
184
|
// Caret ranges.
|
187
185
|
// Meaning is "at least and backwards compatible with"
|
188
|
-
var LONECARET = R
|
189
|
-
src[LONECARET] = '(?:\\^)'
|
186
|
+
var LONECARET = R++
|
187
|
+
src[LONECARET] = '(?:\\^)'
|
190
188
|
|
191
|
-
var CARETTRIM = R
|
192
|
-
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
193
|
-
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
194
|
-
var caretTrimReplace = '$1^'
|
189
|
+
var CARETTRIM = R++
|
190
|
+
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
191
|
+
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
192
|
+
var caretTrimReplace = '$1^'
|
195
193
|
|
196
|
-
var CARET = R
|
197
|
-
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
198
|
-
var CARETLOOSE = R
|
199
|
-
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
194
|
+
var CARET = R++
|
195
|
+
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
196
|
+
var CARETLOOSE = R++
|
197
|
+
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
200
198
|
|
201
199
|
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
202
|
-
var COMPARATORLOOSE = R
|
203
|
-
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
204
|
-
var COMPARATOR = R
|
205
|
-
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
206
|
-
|
200
|
+
var COMPARATORLOOSE = R++
|
201
|
+
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
202
|
+
var COMPARATOR = R++
|
203
|
+
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
207
204
|
|
208
205
|
// An expression to strip any whitespace between the gtlt and the thing
|
209
206
|
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
210
|
-
var COMPARATORTRIM = R
|
207
|
+
var COMPARATORTRIM = R++
|
211
208
|
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
|
212
|
-
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
209
|
+
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
213
210
|
|
214
211
|
// this one has to use the /g flag
|
215
|
-
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
216
|
-
var comparatorTrimReplace = '$1$2$3'
|
217
|
-
|
212
|
+
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
213
|
+
var comparatorTrimReplace = '$1$2$3'
|
218
214
|
|
219
215
|
// Something like `1.2.3 - 1.2.4`
|
220
216
|
// Note that these all use the loose form, because they'll be
|
221
217
|
// checked against either the strict or loose comparator form
|
222
218
|
// later.
|
223
|
-
var HYPHENRANGE = R
|
219
|
+
var HYPHENRANGE = R++
|
224
220
|
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
|
225
221
|
'\\s+-\\s+' +
|
226
222
|
'(' + src[XRANGEPLAIN] + ')' +
|
227
|
-
'\\s*$'
|
223
|
+
'\\s*$'
|
228
224
|
|
229
|
-
var HYPHENRANGELOOSE = R
|
225
|
+
var HYPHENRANGELOOSE = R++
|
230
226
|
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
|
231
227
|
'\\s+-\\s+' +
|
232
228
|
'(' + src[XRANGEPLAINLOOSE] + ')' +
|
233
|
-
'\\s*$'
|
229
|
+
'\\s*$'
|
234
230
|
|
235
231
|
// Star ranges basically just allow anything at all.
|
236
|
-
var STAR = R
|
237
|
-
src[STAR] = '(<|>)?=?\\s*\\*'
|
232
|
+
var STAR = R++
|
233
|
+
src[STAR] = '(<|>)?=?\\s*\\*'
|
238
234
|
|
239
235
|
// Compile to actual regexp objects.
|
240
236
|
// All are flag-free, unless they were created above with a flag.
|
241
237
|
for (var i = 0; i < R; i++) {
|
242
|
-
debug(i, src[i])
|
243
|
-
if (!re[i])
|
244
|
-
re[i] = new RegExp(src[i])
|
238
|
+
debug(i, src[i])
|
239
|
+
if (!re[i]) {
|
240
|
+
re[i] = new RegExp(src[i])
|
241
|
+
}
|
245
242
|
}
|
246
243
|
|
247
|
-
exports.parse = parse
|
248
|
-
function parse(version,
|
249
|
-
if (
|
250
|
-
|
244
|
+
exports.parse = parse
|
245
|
+
function parse (version, options) {
|
246
|
+
if (!options || typeof options !== 'object') {
|
247
|
+
options = {
|
248
|
+
loose: !!options,
|
249
|
+
includePrerelease: false
|
250
|
+
}
|
251
|
+
}
|
251
252
|
|
252
|
-
if (
|
253
|
-
return
|
253
|
+
if (version instanceof SemVer) {
|
254
|
+
return version
|
255
|
+
}
|
254
256
|
|
255
|
-
if (version
|
256
|
-
return null
|
257
|
+
if (typeof version !== 'string') {
|
258
|
+
return null
|
259
|
+
}
|
260
|
+
|
261
|
+
if (version.length > MAX_LENGTH) {
|
262
|
+
return null
|
263
|
+
}
|
257
264
|
|
258
|
-
var r = loose ? re[LOOSE] : re[FULL]
|
259
|
-
if (!r.test(version))
|
260
|
-
return null
|
265
|
+
var r = options.loose ? re[LOOSE] : re[FULL]
|
266
|
+
if (!r.test(version)) {
|
267
|
+
return null
|
268
|
+
}
|
261
269
|
|
262
270
|
try {
|
263
|
-
return new SemVer(version,
|
271
|
+
return new SemVer(version, options)
|
264
272
|
} catch (er) {
|
265
|
-
return null
|
273
|
+
return null
|
266
274
|
}
|
267
275
|
}
|
268
276
|
|
269
|
-
exports.valid = valid
|
270
|
-
function valid(version,
|
271
|
-
var v = parse(version,
|
272
|
-
return v ? v.version : null
|
277
|
+
exports.valid = valid
|
278
|
+
function valid (version, options) {
|
279
|
+
var v = parse(version, options)
|
280
|
+
return v ? v.version : null
|
273
281
|
}
|
274
282
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
return s ? s.version : null;
|
283
|
+
exports.clean = clean
|
284
|
+
function clean (version, options) {
|
285
|
+
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
286
|
+
return s ? s.version : null
|
280
287
|
}
|
281
288
|
|
282
|
-
exports.SemVer = SemVer
|
289
|
+
exports.SemVer = SemVer
|
283
290
|
|
284
|
-
function SemVer(version,
|
291
|
+
function SemVer (version, options) {
|
292
|
+
if (!options || typeof options !== 'object') {
|
293
|
+
options = {
|
294
|
+
loose: !!options,
|
295
|
+
includePrerelease: false
|
296
|
+
}
|
297
|
+
}
|
285
298
|
if (version instanceof SemVer) {
|
286
|
-
if (version.loose === loose)
|
287
|
-
return version
|
288
|
-
else
|
289
|
-
version = version.version
|
299
|
+
if (version.loose === options.loose) {
|
300
|
+
return version
|
301
|
+
} else {
|
302
|
+
version = version.version
|
303
|
+
}
|
290
304
|
} else if (typeof version !== 'string') {
|
291
|
-
throw new TypeError('Invalid Version: ' + version)
|
305
|
+
throw new TypeError('Invalid Version: ' + version)
|
292
306
|
}
|
293
307
|
|
294
|
-
if (version.length > MAX_LENGTH)
|
308
|
+
if (version.length > MAX_LENGTH) {
|
295
309
|
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
310
|
+
}
|
296
311
|
|
297
|
-
if (!(this instanceof SemVer))
|
298
|
-
return new SemVer(version,
|
312
|
+
if (!(this instanceof SemVer)) {
|
313
|
+
return new SemVer(version, options)
|
314
|
+
}
|
299
315
|
|
300
|
-
debug('SemVer', version,
|
301
|
-
this.
|
302
|
-
|
316
|
+
debug('SemVer', version, options)
|
317
|
+
this.options = options
|
318
|
+
this.loose = !!options.loose
|
303
319
|
|
304
|
-
|
305
|
-
|
320
|
+
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
321
|
+
|
322
|
+
if (!m) {
|
323
|
+
throw new TypeError('Invalid Version: ' + version)
|
324
|
+
}
|
306
325
|
|
307
|
-
this.raw = version
|
326
|
+
this.raw = version
|
308
327
|
|
309
328
|
// these are actually numbers
|
310
|
-
this.major = +m[1]
|
311
|
-
this.minor = +m[2]
|
312
|
-
this.patch = +m[3]
|
329
|
+
this.major = +m[1]
|
330
|
+
this.minor = +m[2]
|
331
|
+
this.patch = +m[3]
|
313
332
|
|
314
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0)
|
333
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
315
334
|
throw new TypeError('Invalid major version')
|
335
|
+
}
|
316
336
|
|
317
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0)
|
337
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
318
338
|
throw new TypeError('Invalid minor version')
|
339
|
+
}
|
319
340
|
|
320
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0)
|
341
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
321
342
|
throw new TypeError('Invalid patch version')
|
343
|
+
}
|
322
344
|
|
323
345
|
// numberify any prerelease numeric ids
|
324
|
-
if (!m[4])
|
325
|
-
this.prerelease = []
|
326
|
-
else
|
327
|
-
this.prerelease = m[4].split('.').map(function(id) {
|
346
|
+
if (!m[4]) {
|
347
|
+
this.prerelease = []
|
348
|
+
} else {
|
349
|
+
this.prerelease = m[4].split('.').map(function (id) {
|
328
350
|
if (/^[0-9]+$/.test(id)) {
|
329
|
-
var num = +id
|
330
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER)
|
331
|
-
return num
|
351
|
+
var num = +id
|
352
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
353
|
+
return num
|
354
|
+
}
|
332
355
|
}
|
333
|
-
return id
|
334
|
-
})
|
356
|
+
return id
|
357
|
+
})
|
358
|
+
}
|
335
359
|
|
336
|
-
this.build = m[5] ? m[5].split('.') : []
|
337
|
-
this.format()
|
360
|
+
this.build = m[5] ? m[5].split('.') : []
|
361
|
+
this.format()
|
338
362
|
}
|
339
363
|
|
340
|
-
SemVer.prototype.format = function() {
|
341
|
-
this.version = this.major + '.' + this.minor + '.' + this.patch
|
342
|
-
if (this.prerelease.length)
|
343
|
-
this.version += '-' + this.prerelease.join('.')
|
344
|
-
|
345
|
-
|
364
|
+
SemVer.prototype.format = function () {
|
365
|
+
this.version = this.major + '.' + this.minor + '.' + this.patch
|
366
|
+
if (this.prerelease.length) {
|
367
|
+
this.version += '-' + this.prerelease.join('.')
|
368
|
+
}
|
369
|
+
return this.version
|
370
|
+
}
|
346
371
|
|
347
|
-
SemVer.prototype.toString = function() {
|
348
|
-
return this.version
|
349
|
-
}
|
372
|
+
SemVer.prototype.toString = function () {
|
373
|
+
return this.version
|
374
|
+
}
|
350
375
|
|
351
|
-
SemVer.prototype.compare = function(other) {
|
352
|
-
debug('SemVer.compare', this.version, this.
|
353
|
-
if (!(other instanceof SemVer))
|
354
|
-
other = new SemVer(other, this.
|
376
|
+
SemVer.prototype.compare = function (other) {
|
377
|
+
debug('SemVer.compare', this.version, this.options, other)
|
378
|
+
if (!(other instanceof SemVer)) {
|
379
|
+
other = new SemVer(other, this.options)
|
380
|
+
}
|
355
381
|
|
356
|
-
return this.compareMain(other) || this.comparePre(other)
|
357
|
-
}
|
382
|
+
return this.compareMain(other) || this.comparePre(other)
|
383
|
+
}
|
358
384
|
|
359
|
-
SemVer.prototype.compareMain = function(other) {
|
360
|
-
if (!(other instanceof SemVer))
|
361
|
-
other = new SemVer(other, this.
|
385
|
+
SemVer.prototype.compareMain = function (other) {
|
386
|
+
if (!(other instanceof SemVer)) {
|
387
|
+
other = new SemVer(other, this.options)
|
388
|
+
}
|
362
389
|
|
363
390
|
return compareIdentifiers(this.major, other.major) ||
|
364
391
|
compareIdentifiers(this.minor, other.minor) ||
|
365
|
-
compareIdentifiers(this.patch, other.patch)
|
366
|
-
}
|
392
|
+
compareIdentifiers(this.patch, other.patch)
|
393
|
+
}
|
367
394
|
|
368
|
-
SemVer.prototype.comparePre = function(other) {
|
369
|
-
if (!(other instanceof SemVer))
|
370
|
-
other = new SemVer(other, this.
|
395
|
+
SemVer.prototype.comparePre = function (other) {
|
396
|
+
if (!(other instanceof SemVer)) {
|
397
|
+
other = new SemVer(other, this.options)
|
398
|
+
}
|
371
399
|
|
372
400
|
// NOT having a prerelease is > having one
|
373
|
-
if (this.prerelease.length && !other.prerelease.length)
|
374
|
-
return -1
|
375
|
-
else if (!this.prerelease.length && other.prerelease.length)
|
376
|
-
return 1
|
377
|
-
else if (!this.prerelease.length && !other.prerelease.length)
|
378
|
-
return 0
|
379
|
-
|
380
|
-
|
401
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
402
|
+
return -1
|
403
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
404
|
+
return 1
|
405
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
406
|
+
return 0
|
407
|
+
}
|
408
|
+
|
409
|
+
var i = 0
|
381
410
|
do {
|
382
|
-
var a = this.prerelease[i]
|
383
|
-
var b = other.prerelease[i]
|
384
|
-
debug('prerelease compare', i, a, b)
|
385
|
-
if (a === undefined && b === undefined)
|
386
|
-
return 0
|
387
|
-
else if (b === undefined)
|
388
|
-
return 1
|
389
|
-
else if (a === undefined)
|
390
|
-
return -1
|
391
|
-
else if (a === b)
|
392
|
-
continue
|
393
|
-
else
|
394
|
-
return compareIdentifiers(a, b)
|
395
|
-
|
396
|
-
}
|
411
|
+
var a = this.prerelease[i]
|
412
|
+
var b = other.prerelease[i]
|
413
|
+
debug('prerelease compare', i, a, b)
|
414
|
+
if (a === undefined && b === undefined) {
|
415
|
+
return 0
|
416
|
+
} else if (b === undefined) {
|
417
|
+
return 1
|
418
|
+
} else if (a === undefined) {
|
419
|
+
return -1
|
420
|
+
} else if (a === b) {
|
421
|
+
continue
|
422
|
+
} else {
|
423
|
+
return compareIdentifiers(a, b)
|
424
|
+
}
|
425
|
+
} while (++i)
|
426
|
+
}
|
397
427
|
|
398
428
|
// preminor will bump the version up to the next minor release, and immediately
|
399
429
|
// down to pre-release. premajor and prepatch work the same way.
|
400
|
-
SemVer.prototype.inc = function(release, identifier) {
|
430
|
+
SemVer.prototype.inc = function (release, identifier) {
|
401
431
|
switch (release) {
|
402
432
|
case 'premajor':
|
403
|
-
this.prerelease.length = 0
|
404
|
-
this.patch = 0
|
405
|
-
this.minor = 0
|
406
|
-
this.major
|
407
|
-
this.inc('pre', identifier)
|
408
|
-
break
|
433
|
+
this.prerelease.length = 0
|
434
|
+
this.patch = 0
|
435
|
+
this.minor = 0
|
436
|
+
this.major++
|
437
|
+
this.inc('pre', identifier)
|
438
|
+
break
|
409
439
|
case 'preminor':
|
410
|
-
this.prerelease.length = 0
|
411
|
-
this.patch = 0
|
412
|
-
this.minor
|
413
|
-
this.inc('pre', identifier)
|
414
|
-
break
|
440
|
+
this.prerelease.length = 0
|
441
|
+
this.patch = 0
|
442
|
+
this.minor++
|
443
|
+
this.inc('pre', identifier)
|
444
|
+
break
|
415
445
|
case 'prepatch':
|
416
446
|
// If this is already a prerelease, it will bump to the next version
|
417
447
|
// drop any prereleases that might already exist, since they are not
|
418
448
|
// relevant at this point.
|
419
|
-
this.prerelease.length = 0
|
420
|
-
this.inc('patch', identifier)
|
421
|
-
this.inc('pre', identifier)
|
422
|
-
break
|
449
|
+
this.prerelease.length = 0
|
450
|
+
this.inc('patch', identifier)
|
451
|
+
this.inc('pre', identifier)
|
452
|
+
break
|
423
453
|
// If the input is a non-prerelease version, this acts the same as
|
424
454
|
// prepatch.
|
425
455
|
case 'prerelease':
|
426
|
-
if (this.prerelease.length === 0)
|
427
|
-
this.inc('patch', identifier)
|
428
|
-
|
429
|
-
|
456
|
+
if (this.prerelease.length === 0) {
|
457
|
+
this.inc('patch', identifier)
|
458
|
+
}
|
459
|
+
this.inc('pre', identifier)
|
460
|
+
break
|
430
461
|
|
431
462
|
case 'major':
|
432
463
|
// If this is a pre-major version, bump up to the same major version.
|
433
464
|
// Otherwise increment major.
|
434
465
|
// 1.0.0-5 bumps to 1.0.0
|
435
466
|
// 1.1.0 bumps to 2.0.0
|
436
|
-
if (this.minor !== 0 ||
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
467
|
+
if (this.minor !== 0 ||
|
468
|
+
this.patch !== 0 ||
|
469
|
+
this.prerelease.length === 0) {
|
470
|
+
this.major++
|
471
|
+
}
|
472
|
+
this.minor = 0
|
473
|
+
this.patch = 0
|
474
|
+
this.prerelease = []
|
475
|
+
break
|
442
476
|
case 'minor':
|
443
477
|
// If this is a pre-minor version, bump up to the same minor version.
|
444
478
|
// Otherwise increment minor.
|
445
479
|
// 1.2.0-5 bumps to 1.2.0
|
446
480
|
// 1.2.1 bumps to 1.3.0
|
447
|
-
if (this.patch !== 0 || this.prerelease.length === 0)
|
448
|
-
this.minor
|
449
|
-
|
450
|
-
this.
|
451
|
-
|
481
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
482
|
+
this.minor++
|
483
|
+
}
|
484
|
+
this.patch = 0
|
485
|
+
this.prerelease = []
|
486
|
+
break
|
452
487
|
case 'patch':
|
453
488
|
// If this is not a pre-release version, it will increment the patch.
|
454
489
|
// If it is a pre-release it will bump up to the same patch version.
|
455
490
|
// 1.2.0-5 patches to 1.2.0
|
456
491
|
// 1.2.0 patches to 1.2.1
|
457
|
-
if (this.prerelease.length === 0)
|
458
|
-
this.patch
|
459
|
-
|
460
|
-
|
492
|
+
if (this.prerelease.length === 0) {
|
493
|
+
this.patch++
|
494
|
+
}
|
495
|
+
this.prerelease = []
|
496
|
+
break
|
461
497
|
// This probably shouldn't be used publicly.
|
462
498
|
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
463
499
|
case 'pre':
|
464
|
-
if (this.prerelease.length === 0)
|
465
|
-
this.prerelease = [0]
|
466
|
-
else {
|
467
|
-
var i = this.prerelease.length
|
500
|
+
if (this.prerelease.length === 0) {
|
501
|
+
this.prerelease = [0]
|
502
|
+
} else {
|
503
|
+
var i = this.prerelease.length
|
468
504
|
while (--i >= 0) {
|
469
505
|
if (typeof this.prerelease[i] === 'number') {
|
470
|
-
this.prerelease[i]
|
471
|
-
i = -2
|
506
|
+
this.prerelease[i]++
|
507
|
+
i = -2
|
472
508
|
}
|
473
509
|
}
|
474
|
-
if (i === -1)
|
475
|
-
|
510
|
+
if (i === -1) {
|
511
|
+
// didn't increment anything
|
512
|
+
this.prerelease.push(0)
|
513
|
+
}
|
476
514
|
}
|
477
515
|
if (identifier) {
|
478
516
|
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
479
517
|
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
480
518
|
if (this.prerelease[0] === identifier) {
|
481
|
-
if (isNaN(this.prerelease[1]))
|
482
|
-
this.prerelease = [identifier, 0]
|
483
|
-
|
484
|
-
|
519
|
+
if (isNaN(this.prerelease[1])) {
|
520
|
+
this.prerelease = [identifier, 0]
|
521
|
+
}
|
522
|
+
} else {
|
523
|
+
this.prerelease = [identifier, 0]
|
524
|
+
}
|
485
525
|
}
|
486
|
-
break
|
526
|
+
break
|
487
527
|
|
488
528
|
default:
|
489
|
-
throw new Error('invalid increment argument: ' + release)
|
529
|
+
throw new Error('invalid increment argument: ' + release)
|
490
530
|
}
|
491
|
-
this.format()
|
492
|
-
this.raw = this.version
|
493
|
-
return this
|
494
|
-
}
|
531
|
+
this.format()
|
532
|
+
this.raw = this.version
|
533
|
+
return this
|
534
|
+
}
|
495
535
|
|
496
|
-
exports.inc = inc
|
497
|
-
function inc(version, release, loose, identifier) {
|
498
|
-
if (typeof(loose) === 'string') {
|
499
|
-
identifier = loose
|
500
|
-
loose = undefined
|
536
|
+
exports.inc = inc
|
537
|
+
function inc (version, release, loose, identifier) {
|
538
|
+
if (typeof (loose) === 'string') {
|
539
|
+
identifier = loose
|
540
|
+
loose = undefined
|
501
541
|
}
|
502
542
|
|
503
543
|
try {
|
504
|
-
return new SemVer(version, loose).inc(release, identifier).version
|
544
|
+
return new SemVer(version, loose).inc(release, identifier).version
|
505
545
|
} catch (er) {
|
506
|
-
return null
|
546
|
+
return null
|
507
547
|
}
|
508
548
|
}
|
509
549
|
|
510
|
-
exports.diff = diff
|
511
|
-
function diff(version1, version2) {
|
550
|
+
exports.diff = diff
|
551
|
+
function diff (version1, version2) {
|
512
552
|
if (eq(version1, version2)) {
|
513
|
-
return null
|
553
|
+
return null
|
514
554
|
} else {
|
515
|
-
var v1 = parse(version1)
|
516
|
-
var v2 = parse(version2)
|
555
|
+
var v1 = parse(version1)
|
556
|
+
var v2 = parse(version2)
|
557
|
+
var prefix = ''
|
517
558
|
if (v1.prerelease.length || v2.prerelease.length) {
|
518
|
-
|
519
|
-
|
520
|
-
if (v1[key] !== v2[key]) {
|
521
|
-
return 'pre'+key;
|
522
|
-
}
|
523
|
-
}
|
524
|
-
}
|
525
|
-
return 'prerelease';
|
559
|
+
prefix = 'pre'
|
560
|
+
var defaultResult = 'prerelease'
|
526
561
|
}
|
527
562
|
for (var key in v1) {
|
528
563
|
if (key === 'major' || key === 'minor' || key === 'patch') {
|
529
564
|
if (v1[key] !== v2[key]) {
|
530
|
-
return key
|
565
|
+
return prefix + key
|
531
566
|
}
|
532
567
|
}
|
533
568
|
}
|
569
|
+
return defaultResult // may be undefined
|
534
570
|
}
|
535
571
|
}
|
536
572
|
|
537
|
-
exports.compareIdentifiers = compareIdentifiers
|
573
|
+
exports.compareIdentifiers = compareIdentifiers
|
538
574
|
|
539
|
-
var numeric = /^[0-9]
|
540
|
-
function compareIdentifiers(a, b) {
|
541
|
-
var anum = numeric.test(a)
|
542
|
-
var bnum = numeric.test(b)
|
575
|
+
var numeric = /^[0-9]+$/
|
576
|
+
function compareIdentifiers (a, b) {
|
577
|
+
var anum = numeric.test(a)
|
578
|
+
var bnum = numeric.test(b)
|
543
579
|
|
544
580
|
if (anum && bnum) {
|
545
|
-
a = +a
|
546
|
-
b = +b
|
581
|
+
a = +a
|
582
|
+
b = +b
|
547
583
|
}
|
548
584
|
|
549
|
-
return
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
585
|
+
return a === b ? 0
|
586
|
+
: (anum && !bnum) ? -1
|
587
|
+
: (bnum && !anum) ? 1
|
588
|
+
: a < b ? -1
|
589
|
+
: 1
|
554
590
|
}
|
555
591
|
|
556
|
-
exports.rcompareIdentifiers = rcompareIdentifiers
|
557
|
-
function rcompareIdentifiers(a, b) {
|
558
|
-
return compareIdentifiers(b, a)
|
592
|
+
exports.rcompareIdentifiers = rcompareIdentifiers
|
593
|
+
function rcompareIdentifiers (a, b) {
|
594
|
+
return compareIdentifiers(b, a)
|
559
595
|
}
|
560
596
|
|
561
|
-
exports.major = major
|
562
|
-
function major(a, loose) {
|
563
|
-
return new SemVer(a, loose).major
|
597
|
+
exports.major = major
|
598
|
+
function major (a, loose) {
|
599
|
+
return new SemVer(a, loose).major
|
564
600
|
}
|
565
601
|
|
566
|
-
exports.minor = minor
|
567
|
-
function minor(a, loose) {
|
568
|
-
return new SemVer(a, loose).minor
|
602
|
+
exports.minor = minor
|
603
|
+
function minor (a, loose) {
|
604
|
+
return new SemVer(a, loose).minor
|
569
605
|
}
|
570
606
|
|
571
|
-
exports.patch = patch
|
572
|
-
function patch(a, loose) {
|
573
|
-
return new SemVer(a, loose).patch
|
607
|
+
exports.patch = patch
|
608
|
+
function patch (a, loose) {
|
609
|
+
return new SemVer(a, loose).patch
|
574
610
|
}
|
575
611
|
|
576
|
-
exports.compare = compare
|
577
|
-
function compare(a, b, loose) {
|
578
|
-
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
612
|
+
exports.compare = compare
|
613
|
+
function compare (a, b, loose) {
|
614
|
+
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
579
615
|
}
|
580
616
|
|
581
|
-
exports.compareLoose = compareLoose
|
582
|
-
function compareLoose(a, b) {
|
583
|
-
return compare(a, b, true)
|
617
|
+
exports.compareLoose = compareLoose
|
618
|
+
function compareLoose (a, b) {
|
619
|
+
return compare(a, b, true)
|
584
620
|
}
|
585
621
|
|
586
|
-
exports.rcompare = rcompare
|
587
|
-
function rcompare(a, b, loose) {
|
588
|
-
return compare(b, a, loose)
|
622
|
+
exports.rcompare = rcompare
|
623
|
+
function rcompare (a, b, loose) {
|
624
|
+
return compare(b, a, loose)
|
589
625
|
}
|
590
626
|
|
591
|
-
exports.sort = sort
|
592
|
-
function sort(list, loose) {
|
593
|
-
return list.sort(function(a, b) {
|
594
|
-
return exports.compare(a, b, loose)
|
595
|
-
})
|
627
|
+
exports.sort = sort
|
628
|
+
function sort (list, loose) {
|
629
|
+
return list.sort(function (a, b) {
|
630
|
+
return exports.compare(a, b, loose)
|
631
|
+
})
|
596
632
|
}
|
597
633
|
|
598
|
-
exports.rsort = rsort
|
599
|
-
function rsort(list, loose) {
|
600
|
-
return list.sort(function(a, b) {
|
601
|
-
return exports.rcompare(a, b, loose)
|
602
|
-
})
|
634
|
+
exports.rsort = rsort
|
635
|
+
function rsort (list, loose) {
|
636
|
+
return list.sort(function (a, b) {
|
637
|
+
return exports.rcompare(a, b, loose)
|
638
|
+
})
|
603
639
|
}
|
604
640
|
|
605
|
-
exports.gt = gt
|
606
|
-
function gt(a, b, loose) {
|
607
|
-
return compare(a, b, loose) > 0
|
641
|
+
exports.gt = gt
|
642
|
+
function gt (a, b, loose) {
|
643
|
+
return compare(a, b, loose) > 0
|
608
644
|
}
|
609
645
|
|
610
|
-
exports.lt = lt
|
611
|
-
function lt(a, b, loose) {
|
612
|
-
return compare(a, b, loose) < 0
|
646
|
+
exports.lt = lt
|
647
|
+
function lt (a, b, loose) {
|
648
|
+
return compare(a, b, loose) < 0
|
613
649
|
}
|
614
650
|
|
615
|
-
exports.eq = eq
|
616
|
-
function eq(a, b, loose) {
|
617
|
-
return compare(a, b, loose) === 0
|
651
|
+
exports.eq = eq
|
652
|
+
function eq (a, b, loose) {
|
653
|
+
return compare(a, b, loose) === 0
|
618
654
|
}
|
619
655
|
|
620
|
-
exports.neq = neq
|
621
|
-
function neq(a, b, loose) {
|
622
|
-
return compare(a, b, loose) !== 0
|
656
|
+
exports.neq = neq
|
657
|
+
function neq (a, b, loose) {
|
658
|
+
return compare(a, b, loose) !== 0
|
623
659
|
}
|
624
660
|
|
625
|
-
exports.gte = gte
|
626
|
-
function gte(a, b, loose) {
|
627
|
-
return compare(a, b, loose) >= 0
|
661
|
+
exports.gte = gte
|
662
|
+
function gte (a, b, loose) {
|
663
|
+
return compare(a, b, loose) >= 0
|
628
664
|
}
|
629
665
|
|
630
|
-
exports.lte = lte
|
631
|
-
function lte(a, b, loose) {
|
632
|
-
return compare(a, b, loose) <= 0
|
666
|
+
exports.lte = lte
|
667
|
+
function lte (a, b, loose) {
|
668
|
+
return compare(a, b, loose) <= 0
|
633
669
|
}
|
634
670
|
|
635
|
-
exports.cmp = cmp
|
636
|
-
function cmp(a, op, b, loose) {
|
637
|
-
var ret;
|
671
|
+
exports.cmp = cmp
|
672
|
+
function cmp (a, op, b, loose) {
|
638
673
|
switch (op) {
|
639
674
|
case '===':
|
640
|
-
if (typeof a === 'object')
|
641
|
-
|
642
|
-
|
643
|
-
|
675
|
+
if (typeof a === 'object')
|
676
|
+
a = a.version
|
677
|
+
if (typeof b === 'object')
|
678
|
+
b = b.version
|
679
|
+
return a === b
|
680
|
+
|
644
681
|
case '!==':
|
645
|
-
if (typeof a === 'object')
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
case '
|
652
|
-
case '
|
653
|
-
case '
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
682
|
+
if (typeof a === 'object')
|
683
|
+
a = a.version
|
684
|
+
if (typeof b === 'object')
|
685
|
+
b = b.version
|
686
|
+
return a !== b
|
687
|
+
|
688
|
+
case '':
|
689
|
+
case '=':
|
690
|
+
case '==':
|
691
|
+
return eq(a, b, loose)
|
692
|
+
|
693
|
+
case '!=':
|
694
|
+
return neq(a, b, loose)
|
695
|
+
|
696
|
+
case '>':
|
697
|
+
return gt(a, b, loose)
|
698
|
+
|
699
|
+
case '>=':
|
700
|
+
return gte(a, b, loose)
|
701
|
+
|
702
|
+
case '<':
|
703
|
+
return lt(a, b, loose)
|
704
|
+
|
705
|
+
case '<=':
|
706
|
+
return lte(a, b, loose)
|
707
|
+
|
708
|
+
default:
|
709
|
+
throw new TypeError('Invalid operator: ' + op)
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
exports.Comparator = Comparator
|
714
|
+
function Comparator (comp, options) {
|
715
|
+
if (!options || typeof options !== 'object') {
|
716
|
+
options = {
|
717
|
+
loose: !!options,
|
718
|
+
includePrerelease: false
|
719
|
+
}
|
720
|
+
}
|
721
|
+
|
662
722
|
if (comp instanceof Comparator) {
|
663
|
-
if (comp.loose === loose)
|
664
|
-
return comp
|
665
|
-
else
|
666
|
-
comp = comp.value
|
723
|
+
if (comp.loose === !!options.loose) {
|
724
|
+
return comp
|
725
|
+
} else {
|
726
|
+
comp = comp.value
|
727
|
+
}
|
667
728
|
}
|
668
729
|
|
669
|
-
if (!(this instanceof Comparator))
|
670
|
-
return new Comparator(comp,
|
730
|
+
if (!(this instanceof Comparator)) {
|
731
|
+
return new Comparator(comp, options)
|
732
|
+
}
|
671
733
|
|
672
|
-
debug('comparator', comp,
|
673
|
-
this.
|
674
|
-
this.
|
734
|
+
debug('comparator', comp, options)
|
735
|
+
this.options = options
|
736
|
+
this.loose = !!options.loose
|
737
|
+
this.parse(comp)
|
675
738
|
|
676
|
-
if (this.semver === ANY)
|
677
|
-
this.value = ''
|
678
|
-
else
|
679
|
-
this.value = this.operator + this.semver.version
|
739
|
+
if (this.semver === ANY) {
|
740
|
+
this.value = ''
|
741
|
+
} else {
|
742
|
+
this.value = this.operator + this.semver.version
|
743
|
+
}
|
680
744
|
|
681
|
-
debug('comp', this)
|
745
|
+
debug('comp', this)
|
682
746
|
}
|
683
747
|
|
684
|
-
var ANY = {}
|
685
|
-
Comparator.prototype.parse = function(comp) {
|
686
|
-
var r = this.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
687
|
-
var m = comp.match(r)
|
748
|
+
var ANY = {}
|
749
|
+
Comparator.prototype.parse = function (comp) {
|
750
|
+
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
751
|
+
var m = comp.match(r)
|
688
752
|
|
689
|
-
if (!m)
|
690
|
-
throw new TypeError('Invalid comparator: ' + comp)
|
753
|
+
if (!m) {
|
754
|
+
throw new TypeError('Invalid comparator: ' + comp)
|
755
|
+
}
|
691
756
|
|
692
|
-
this.operator = m[1]
|
693
|
-
if (this.operator === '=')
|
694
|
-
this.operator = ''
|
757
|
+
this.operator = m[1]
|
758
|
+
if (this.operator === '=') {
|
759
|
+
this.operator = ''
|
760
|
+
}
|
695
761
|
|
696
762
|
// if it literally is just '>' or '' then allow anything.
|
697
|
-
if (!m[2])
|
698
|
-
this.semver = ANY
|
699
|
-
else
|
700
|
-
this.semver = new SemVer(m[2], this.loose)
|
701
|
-
}
|
763
|
+
if (!m[2]) {
|
764
|
+
this.semver = ANY
|
765
|
+
} else {
|
766
|
+
this.semver = new SemVer(m[2], this.options.loose)
|
767
|
+
}
|
768
|
+
}
|
702
769
|
|
703
|
-
Comparator.prototype.toString = function() {
|
704
|
-
return this.value
|
705
|
-
}
|
770
|
+
Comparator.prototype.toString = function () {
|
771
|
+
return this.value
|
772
|
+
}
|
706
773
|
|
707
|
-
Comparator.prototype.test = function(version) {
|
708
|
-
debug('Comparator.test', version, this.loose)
|
774
|
+
Comparator.prototype.test = function (version) {
|
775
|
+
debug('Comparator.test', version, this.options.loose)
|
709
776
|
|
710
|
-
if (this.semver === ANY)
|
711
|
-
return true
|
777
|
+
if (this.semver === ANY) {
|
778
|
+
return true
|
779
|
+
}
|
712
780
|
|
713
|
-
if (typeof version === 'string')
|
714
|
-
version = new SemVer(version, this.
|
781
|
+
if (typeof version === 'string') {
|
782
|
+
version = new SemVer(version, this.options)
|
783
|
+
}
|
715
784
|
|
716
|
-
return cmp(version, this.operator, this.semver, this.
|
717
|
-
}
|
785
|
+
return cmp(version, this.operator, this.semver, this.options)
|
786
|
+
}
|
718
787
|
|
719
|
-
Comparator.prototype.intersects = function(comp,
|
788
|
+
Comparator.prototype.intersects = function (comp, options) {
|
720
789
|
if (!(comp instanceof Comparator)) {
|
721
|
-
throw new TypeError('a Comparator is required')
|
790
|
+
throw new TypeError('a Comparator is required')
|
791
|
+
}
|
792
|
+
|
793
|
+
if (!options || typeof options !== 'object') {
|
794
|
+
options = {
|
795
|
+
loose: !!options,
|
796
|
+
includePrerelease: false
|
797
|
+
}
|
722
798
|
}
|
723
799
|
|
724
|
-
var rangeTmp
|
800
|
+
var rangeTmp
|
725
801
|
|
726
802
|
if (this.operator === '') {
|
727
|
-
rangeTmp = new Range(comp.value,
|
728
|
-
return satisfies(this.value, rangeTmp,
|
803
|
+
rangeTmp = new Range(comp.value, options)
|
804
|
+
return satisfies(this.value, rangeTmp, options)
|
729
805
|
} else if (comp.operator === '') {
|
730
|
-
rangeTmp = new Range(this.value,
|
731
|
-
return satisfies(comp.semver, rangeTmp,
|
806
|
+
rangeTmp = new Range(this.value, options)
|
807
|
+
return satisfies(comp.semver, rangeTmp, options)
|
732
808
|
}
|
733
809
|
|
734
810
|
var sameDirectionIncreasing =
|
735
811
|
(this.operator === '>=' || this.operator === '>') &&
|
736
|
-
(comp.operator === '>=' || comp.operator === '>')
|
812
|
+
(comp.operator === '>=' || comp.operator === '>')
|
737
813
|
var sameDirectionDecreasing =
|
738
814
|
(this.operator === '<=' || this.operator === '<') &&
|
739
|
-
(comp.operator === '<=' || comp.operator === '<')
|
740
|
-
var sameSemVer = this.semver.version === comp.semver.version
|
815
|
+
(comp.operator === '<=' || comp.operator === '<')
|
816
|
+
var sameSemVer = this.semver.version === comp.semver.version
|
741
817
|
var differentDirectionsInclusive =
|
742
818
|
(this.operator === '>=' || this.operator === '<=') &&
|
743
|
-
(comp.operator === '>=' || comp.operator === '<=')
|
819
|
+
(comp.operator === '>=' || comp.operator === '<=')
|
744
820
|
var oppositeDirectionsLessThan =
|
745
|
-
cmp(this.semver, '<', comp.semver,
|
821
|
+
cmp(this.semver, '<', comp.semver, options) &&
|
746
822
|
((this.operator === '>=' || this.operator === '>') &&
|
747
|
-
(comp.operator === '<=' || comp.operator === '<'))
|
823
|
+
(comp.operator === '<=' || comp.operator === '<'))
|
748
824
|
var oppositeDirectionsGreaterThan =
|
749
|
-
cmp(this.semver, '>', comp.semver,
|
825
|
+
cmp(this.semver, '>', comp.semver, options) &&
|
750
826
|
((this.operator === '<=' || this.operator === '<') &&
|
751
|
-
(comp.operator === '>=' || comp.operator === '>'))
|
827
|
+
(comp.operator === '>=' || comp.operator === '>'))
|
752
828
|
|
753
829
|
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
754
830
|
(sameSemVer && differentDirectionsInclusive) ||
|
755
|
-
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
756
|
-
}
|
831
|
+
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
832
|
+
}
|
757
833
|
|
834
|
+
exports.Range = Range
|
835
|
+
function Range (range, options) {
|
836
|
+
if (!options || typeof options !== 'object') {
|
837
|
+
options = {
|
838
|
+
loose: !!options,
|
839
|
+
includePrerelease: false
|
840
|
+
}
|
841
|
+
}
|
758
842
|
|
759
|
-
exports.Range = Range;
|
760
|
-
function Range(range, loose) {
|
761
843
|
if (range instanceof Range) {
|
762
|
-
if (range.loose === loose
|
763
|
-
|
844
|
+
if (range.loose === !!options.loose &&
|
845
|
+
range.includePrerelease === !!options.includePrerelease) {
|
846
|
+
return range
|
764
847
|
} else {
|
765
|
-
return new Range(range.raw,
|
848
|
+
return new Range(range.raw, options)
|
766
849
|
}
|
767
850
|
}
|
768
851
|
|
769
852
|
if (range instanceof Comparator) {
|
770
|
-
return new Range(range.value,
|
853
|
+
return new Range(range.value, options)
|
771
854
|
}
|
772
855
|
|
773
|
-
if (!(this instanceof Range))
|
774
|
-
return new Range(range,
|
856
|
+
if (!(this instanceof Range)) {
|
857
|
+
return new Range(range, options)
|
858
|
+
}
|
775
859
|
|
776
|
-
this.
|
860
|
+
this.options = options
|
861
|
+
this.loose = !!options.loose
|
862
|
+
this.includePrerelease = !!options.includePrerelease
|
777
863
|
|
778
864
|
// First, split based on boolean or ||
|
779
|
-
this.raw = range
|
780
|
-
this.set = range.split(/\s*\|\|\s*/).map(function(range) {
|
781
|
-
return this.parseRange(range.trim())
|
782
|
-
}, this).filter(function(c) {
|
865
|
+
this.raw = range
|
866
|
+
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
867
|
+
return this.parseRange(range.trim())
|
868
|
+
}, this).filter(function (c) {
|
783
869
|
// throw out any that are not relevant for whatever reason
|
784
|
-
return c.length
|
785
|
-
})
|
870
|
+
return c.length
|
871
|
+
})
|
786
872
|
|
787
873
|
if (!this.set.length) {
|
788
|
-
throw new TypeError('Invalid SemVer Range: ' + range)
|
874
|
+
throw new TypeError('Invalid SemVer Range: ' + range)
|
789
875
|
}
|
790
876
|
|
791
|
-
this.format()
|
877
|
+
this.format()
|
792
878
|
}
|
793
879
|
|
794
|
-
Range.prototype.format = function() {
|
795
|
-
this.range = this.set.map(function(comps) {
|
796
|
-
return comps.join(' ').trim()
|
797
|
-
}).join('||').trim()
|
798
|
-
return this.range
|
799
|
-
}
|
880
|
+
Range.prototype.format = function () {
|
881
|
+
this.range = this.set.map(function (comps) {
|
882
|
+
return comps.join(' ').trim()
|
883
|
+
}).join('||').trim()
|
884
|
+
return this.range
|
885
|
+
}
|
800
886
|
|
801
|
-
Range.prototype.toString = function() {
|
802
|
-
return this.range
|
803
|
-
}
|
887
|
+
Range.prototype.toString = function () {
|
888
|
+
return this.range
|
889
|
+
}
|
804
890
|
|
805
|
-
Range.prototype.parseRange = function(range) {
|
806
|
-
var loose = this.loose
|
807
|
-
range = range.trim()
|
808
|
-
debug('range', range, loose);
|
891
|
+
Range.prototype.parseRange = function (range) {
|
892
|
+
var loose = this.options.loose
|
893
|
+
range = range.trim()
|
809
894
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
810
|
-
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
811
|
-
range = range.replace(hr, hyphenReplace)
|
812
|
-
debug('hyphen replace', range)
|
895
|
+
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
896
|
+
range = range.replace(hr, hyphenReplace)
|
897
|
+
debug('hyphen replace', range)
|
813
898
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
814
|
-
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
815
|
-
debug('comparator trim', range, re[COMPARATORTRIM])
|
899
|
+
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
900
|
+
debug('comparator trim', range, re[COMPARATORTRIM])
|
816
901
|
|
817
902
|
// `~ 1.2.3` => `~1.2.3`
|
818
|
-
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
903
|
+
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
819
904
|
|
820
905
|
// `^ 1.2.3` => `^1.2.3`
|
821
|
-
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
906
|
+
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
822
907
|
|
823
908
|
// normalize spaces
|
824
|
-
range = range.split(/\s+/).join(' ')
|
909
|
+
range = range.split(/\s+/).join(' ')
|
825
910
|
|
826
911
|
// At this point, the range is completely trimmed and
|
827
912
|
// ready to be split into comparators.
|
828
913
|
|
829
|
-
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
830
|
-
var set = range.split(' ').map(function(comp) {
|
831
|
-
return parseComparator(comp,
|
832
|
-
}).join(' ').split(/\s+/)
|
833
|
-
if (this.loose) {
|
914
|
+
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
915
|
+
var set = range.split(' ').map(function (comp) {
|
916
|
+
return parseComparator(comp, this.options)
|
917
|
+
}, this).join(' ').split(/\s+/)
|
918
|
+
if (this.options.loose) {
|
834
919
|
// in loose mode, throw out any that are not valid comparators
|
835
|
-
set = set.filter(function(comp) {
|
836
|
-
return !!comp.match(compRe)
|
837
|
-
})
|
920
|
+
set = set.filter(function (comp) {
|
921
|
+
return !!comp.match(compRe)
|
922
|
+
})
|
838
923
|
}
|
839
|
-
set = set.map(function(comp) {
|
840
|
-
return new Comparator(comp,
|
841
|
-
})
|
924
|
+
set = set.map(function (comp) {
|
925
|
+
return new Comparator(comp, this.options)
|
926
|
+
}, this)
|
842
927
|
|
843
|
-
return set
|
844
|
-
}
|
928
|
+
return set
|
929
|
+
}
|
845
930
|
|
846
|
-
Range.prototype.intersects = function(range,
|
931
|
+
Range.prototype.intersects = function (range, options) {
|
847
932
|
if (!(range instanceof Range)) {
|
848
|
-
throw new TypeError('a Range is required')
|
933
|
+
throw new TypeError('a Range is required')
|
849
934
|
}
|
850
935
|
|
851
|
-
return this.set.some(function(thisComparators) {
|
852
|
-
return thisComparators.every(function(thisComparator) {
|
853
|
-
return range.set.some(function(rangeComparators) {
|
854
|
-
return rangeComparators.every(function(rangeComparator) {
|
855
|
-
return thisComparator.intersects(rangeComparator,
|
856
|
-
})
|
857
|
-
})
|
858
|
-
})
|
859
|
-
})
|
860
|
-
}
|
936
|
+
return this.set.some(function (thisComparators) {
|
937
|
+
return thisComparators.every(function (thisComparator) {
|
938
|
+
return range.set.some(function (rangeComparators) {
|
939
|
+
return rangeComparators.every(function (rangeComparator) {
|
940
|
+
return thisComparator.intersects(rangeComparator, options)
|
941
|
+
})
|
942
|
+
})
|
943
|
+
})
|
944
|
+
})
|
945
|
+
}
|
861
946
|
|
862
947
|
// Mostly just for testing and legacy API reasons
|
863
|
-
exports.toComparators = toComparators
|
864
|
-
function toComparators(range,
|
865
|
-
return new Range(range,
|
866
|
-
return comp.map(function(c) {
|
867
|
-
return c.value
|
868
|
-
}).join(' ').trim().split(' ')
|
869
|
-
})
|
948
|
+
exports.toComparators = toComparators
|
949
|
+
function toComparators (range, options) {
|
950
|
+
return new Range(range, options).set.map(function (comp) {
|
951
|
+
return comp.map(function (c) {
|
952
|
+
return c.value
|
953
|
+
}).join(' ').trim().split(' ')
|
954
|
+
})
|
870
955
|
}
|
871
956
|
|
872
957
|
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
873
958
|
// already replaced the hyphen ranges
|
874
959
|
// turn into a set of JUST comparators.
|
875
|
-
function parseComparator(comp,
|
876
|
-
debug('comp', comp)
|
877
|
-
comp = replaceCarets(comp,
|
878
|
-
debug('caret', comp)
|
879
|
-
comp = replaceTildes(comp,
|
880
|
-
debug('tildes', comp)
|
881
|
-
comp = replaceXRanges(comp,
|
882
|
-
debug('xrange', comp)
|
883
|
-
comp = replaceStars(comp,
|
884
|
-
debug('stars', comp)
|
885
|
-
return comp
|
960
|
+
function parseComparator (comp, options) {
|
961
|
+
debug('comp', comp, options)
|
962
|
+
comp = replaceCarets(comp, options)
|
963
|
+
debug('caret', comp)
|
964
|
+
comp = replaceTildes(comp, options)
|
965
|
+
debug('tildes', comp)
|
966
|
+
comp = replaceXRanges(comp, options)
|
967
|
+
debug('xrange', comp)
|
968
|
+
comp = replaceStars(comp, options)
|
969
|
+
debug('stars', comp)
|
970
|
+
return comp
|
886
971
|
}
|
887
972
|
|
888
|
-
function isX(id) {
|
889
|
-
return !id || id.toLowerCase() === 'x' || id === '*'
|
973
|
+
function isX (id) {
|
974
|
+
return !id || id.toLowerCase() === 'x' || id === '*'
|
890
975
|
}
|
891
976
|
|
892
977
|
// ~, ~> --> * (any, kinda silly)
|
@@ -895,39 +980,38 @@ function isX(id) {
|
|
895
980
|
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
896
981
|
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
897
982
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
898
|
-
function replaceTildes(comp,
|
899
|
-
return comp.trim().split(/\s+/).map(function(comp) {
|
900
|
-
return replaceTilde(comp,
|
901
|
-
}).join(' ')
|
902
|
-
}
|
903
|
-
|
904
|
-
function replaceTilde(comp,
|
905
|
-
var r = loose ? re[TILDELOOSE] : re[TILDE]
|
906
|
-
return comp.replace(r, function(_, M, m, p, pr) {
|
907
|
-
debug('tilde', comp, _, M, m, p, pr)
|
908
|
-
var ret
|
909
|
-
|
910
|
-
if (isX(M))
|
911
|
-
ret = ''
|
912
|
-
else if (isX(m))
|
913
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
914
|
-
else if (isX(p))
|
983
|
+
function replaceTildes (comp, options) {
|
984
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
985
|
+
return replaceTilde(comp, options)
|
986
|
+
}).join(' ')
|
987
|
+
}
|
988
|
+
|
989
|
+
function replaceTilde (comp, options) {
|
990
|
+
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
|
991
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
992
|
+
debug('tilde', comp, _, M, m, p, pr)
|
993
|
+
var ret
|
994
|
+
|
995
|
+
if (isX(M)) {
|
996
|
+
ret = ''
|
997
|
+
} else if (isX(m)) {
|
998
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
999
|
+
} else if (isX(p)) {
|
915
1000
|
// ~1.2 == >=1.2.0 <1.3.0
|
916
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
917
|
-
else if (pr) {
|
918
|
-
debug('replaceTilde pr', pr)
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
' <' + M + '.' + (+m + 1) + '.0';
|
923
|
-
} else
|
1001
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1002
|
+
} else if (pr) {
|
1003
|
+
debug('replaceTilde pr', pr)
|
1004
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1005
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1006
|
+
} else {
|
924
1007
|
// ~1.2.3 == >=1.2.3 <1.3.0
|
925
1008
|
ret = '>=' + M + '.' + m + '.' + p +
|
926
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
1009
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1010
|
+
}
|
927
1011
|
|
928
|
-
debug('tilde return', ret)
|
929
|
-
return ret
|
930
|
-
})
|
1012
|
+
debug('tilde return', ret)
|
1013
|
+
return ret
|
1014
|
+
})
|
931
1015
|
}
|
932
1016
|
|
933
1017
|
// ^ --> * (any, kinda silly)
|
@@ -936,138 +1020,144 @@ function replaceTilde(comp, loose) {
|
|
936
1020
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
937
1021
|
// ^1.2.3 --> >=1.2.3 <2.0.0
|
938
1022
|
// ^1.2.0 --> >=1.2.0 <2.0.0
|
939
|
-
function replaceCarets(comp,
|
940
|
-
return comp.trim().split(/\s+/).map(function(comp) {
|
941
|
-
return replaceCaret(comp,
|
942
|
-
}).join(' ')
|
943
|
-
}
|
944
|
-
|
945
|
-
function replaceCaret(comp,
|
946
|
-
debug('caret', comp,
|
947
|
-
var r = loose ? re[CARETLOOSE] : re[CARET]
|
948
|
-
return comp.replace(r, function(_, M, m, p, pr) {
|
949
|
-
debug('caret', comp, _, M, m, p, pr)
|
950
|
-
var ret
|
951
|
-
|
952
|
-
if (isX(M))
|
953
|
-
ret = ''
|
954
|
-
else if (isX(m))
|
955
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
956
|
-
else if (isX(p)) {
|
957
|
-
if (M === '0')
|
958
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
959
|
-
else
|
960
|
-
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
1023
|
+
function replaceCarets (comp, options) {
|
1024
|
+
return comp.trim().split(/\s+/).map(function (comp) {
|
1025
|
+
return replaceCaret(comp, options)
|
1026
|
+
}).join(' ')
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
function replaceCaret (comp, options) {
|
1030
|
+
debug('caret', comp, options)
|
1031
|
+
var r = options.loose ? re[CARETLOOSE] : re[CARET]
|
1032
|
+
return comp.replace(r, function (_, M, m, p, pr) {
|
1033
|
+
debug('caret', comp, _, M, m, p, pr)
|
1034
|
+
var ret
|
1035
|
+
|
1036
|
+
if (isX(M)) {
|
1037
|
+
ret = ''
|
1038
|
+
} else if (isX(m)) {
|
1039
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1040
|
+
} else if (isX(p)) {
|
1041
|
+
if (M === '0') {
|
1042
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1043
|
+
} else {
|
1044
|
+
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
1045
|
+
}
|
961
1046
|
} else if (pr) {
|
962
|
-
debug('replaceCaret pr', pr)
|
963
|
-
if (pr.charAt(0) !== '-')
|
964
|
-
pr = '-' + pr;
|
1047
|
+
debug('replaceCaret pr', pr)
|
965
1048
|
if (M === '0') {
|
966
|
-
if (m === '0')
|
967
|
-
ret = '>=' + M + '.' + m + '.' + p + pr +
|
968
|
-
' <' + M + '.' + m + '.' + (+p + 1)
|
969
|
-
else
|
970
|
-
ret = '>=' + M + '.' + m + '.' + p + pr +
|
971
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
972
|
-
|
973
|
-
|
974
|
-
|
1049
|
+
if (m === '0') {
|
1050
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1051
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
1052
|
+
} else {
|
1053
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1054
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1055
|
+
}
|
1056
|
+
} else {
|
1057
|
+
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
1058
|
+
' <' + (+M + 1) + '.0.0'
|
1059
|
+
}
|
975
1060
|
} else {
|
976
|
-
debug('no pr')
|
1061
|
+
debug('no pr')
|
977
1062
|
if (M === '0') {
|
978
|
-
if (m === '0')
|
1063
|
+
if (m === '0') {
|
979
1064
|
ret = '>=' + M + '.' + m + '.' + p +
|
980
|
-
' <' + M + '.' + m + '.' + (+p + 1)
|
981
|
-
else
|
1065
|
+
' <' + M + '.' + m + '.' + (+p + 1)
|
1066
|
+
} else {
|
982
1067
|
ret = '>=' + M + '.' + m + '.' + p +
|
983
|
-
' <' + M + '.' + (+m + 1) + '.0'
|
984
|
-
|
1068
|
+
' <' + M + '.' + (+m + 1) + '.0'
|
1069
|
+
}
|
1070
|
+
} else {
|
985
1071
|
ret = '>=' + M + '.' + m + '.' + p +
|
986
|
-
' <' + (+M + 1) + '.0.0'
|
1072
|
+
' <' + (+M + 1) + '.0.0'
|
1073
|
+
}
|
987
1074
|
}
|
988
1075
|
|
989
|
-
debug('caret return', ret)
|
990
|
-
return ret
|
991
|
-
})
|
1076
|
+
debug('caret return', ret)
|
1077
|
+
return ret
|
1078
|
+
})
|
992
1079
|
}
|
993
1080
|
|
994
|
-
function replaceXRanges(comp,
|
995
|
-
debug('replaceXRanges', comp,
|
996
|
-
return comp.split(/\s+/).map(function(comp) {
|
997
|
-
return replaceXRange(comp,
|
998
|
-
}).join(' ')
|
1081
|
+
function replaceXRanges (comp, options) {
|
1082
|
+
debug('replaceXRanges', comp, options)
|
1083
|
+
return comp.split(/\s+/).map(function (comp) {
|
1084
|
+
return replaceXRange(comp, options)
|
1085
|
+
}).join(' ')
|
999
1086
|
}
|
1000
1087
|
|
1001
|
-
function replaceXRange(comp,
|
1002
|
-
comp = comp.trim()
|
1003
|
-
var r = loose ? re[XRANGELOOSE] : re[XRANGE]
|
1004
|
-
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
|
1005
|
-
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
1006
|
-
var xM = isX(M)
|
1007
|
-
var xm = xM || isX(m)
|
1008
|
-
var xp = xm || isX(p)
|
1009
|
-
var anyX = xp
|
1010
|
-
|
1011
|
-
if (gtlt === '=' && anyX)
|
1012
|
-
gtlt = ''
|
1088
|
+
function replaceXRange (comp, options) {
|
1089
|
+
comp = comp.trim()
|
1090
|
+
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
|
1091
|
+
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
1092
|
+
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
1093
|
+
var xM = isX(M)
|
1094
|
+
var xm = xM || isX(m)
|
1095
|
+
var xp = xm || isX(p)
|
1096
|
+
var anyX = xp
|
1097
|
+
|
1098
|
+
if (gtlt === '=' && anyX) {
|
1099
|
+
gtlt = ''
|
1100
|
+
}
|
1013
1101
|
|
1014
1102
|
if (xM) {
|
1015
1103
|
if (gtlt === '>' || gtlt === '<') {
|
1016
1104
|
// nothing is allowed
|
1017
|
-
ret = '<0.0.0'
|
1105
|
+
ret = '<0.0.0'
|
1018
1106
|
} else {
|
1019
1107
|
// nothing is forbidden
|
1020
|
-
ret = '*'
|
1108
|
+
ret = '*'
|
1021
1109
|
}
|
1022
1110
|
} else if (gtlt && anyX) {
|
1111
|
+
// we know patch is an x, because we have any x at all.
|
1023
1112
|
// replace X with 0
|
1024
|
-
if (xm)
|
1025
|
-
m = 0
|
1026
|
-
|
1027
|
-
|
1113
|
+
if (xm) {
|
1114
|
+
m = 0
|
1115
|
+
}
|
1116
|
+
p = 0
|
1028
1117
|
|
1029
1118
|
if (gtlt === '>') {
|
1030
1119
|
// >1 => >=2.0.0
|
1031
1120
|
// >1.2 => >=1.3.0
|
1032
1121
|
// >1.2.3 => >= 1.2.4
|
1033
|
-
gtlt = '>='
|
1122
|
+
gtlt = '>='
|
1034
1123
|
if (xm) {
|
1035
|
-
M = +M + 1
|
1036
|
-
m = 0
|
1037
|
-
p = 0
|
1038
|
-
} else
|
1039
|
-
m = +m + 1
|
1040
|
-
p = 0
|
1124
|
+
M = +M + 1
|
1125
|
+
m = 0
|
1126
|
+
p = 0
|
1127
|
+
} else {
|
1128
|
+
m = +m + 1
|
1129
|
+
p = 0
|
1041
1130
|
}
|
1042
1131
|
} else if (gtlt === '<=') {
|
1043
1132
|
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
1044
1133
|
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
1045
|
-
gtlt = '<'
|
1046
|
-
if (xm)
|
1047
|
-
M = +M + 1
|
1048
|
-
else
|
1049
|
-
m = +m + 1
|
1134
|
+
gtlt = '<'
|
1135
|
+
if (xm) {
|
1136
|
+
M = +M + 1
|
1137
|
+
} else {
|
1138
|
+
m = +m + 1
|
1139
|
+
}
|
1050
1140
|
}
|
1051
1141
|
|
1052
|
-
ret = gtlt + M + '.' + m + '.' + p
|
1142
|
+
ret = gtlt + M + '.' + m + '.' + p
|
1053
1143
|
} else if (xm) {
|
1054
|
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1144
|
+
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
1055
1145
|
} else if (xp) {
|
1056
|
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1146
|
+
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
1057
1147
|
}
|
1058
1148
|
|
1059
|
-
debug('xRange return', ret)
|
1149
|
+
debug('xRange return', ret)
|
1060
1150
|
|
1061
|
-
return ret
|
1062
|
-
})
|
1151
|
+
return ret
|
1152
|
+
})
|
1063
1153
|
}
|
1064
1154
|
|
1065
1155
|
// Because * is AND-ed with everything else in the comparator,
|
1066
1156
|
// and '' means "any version", just remove the *s entirely.
|
1067
|
-
function replaceStars(comp,
|
1068
|
-
debug('replaceStars', comp,
|
1157
|
+
function replaceStars (comp, options) {
|
1158
|
+
debug('replaceStars', comp, options)
|
1069
1159
|
// Looseness is ignored here. star is always as loose as it gets!
|
1070
|
-
return comp.trim().replace(re[STAR], '')
|
1160
|
+
return comp.trim().replace(re[STAR], '')
|
1071
1161
|
}
|
1072
1162
|
|
1073
1163
|
// This function is passed to string.replace(re[HYPHENRANGE])
|
@@ -1075,250 +1165,319 @@ function replaceStars(comp, loose) {
|
|
1075
1165
|
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
1076
1166
|
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
1077
1167
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
1078
|
-
function hyphenReplace($0,
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
if (isX(tM))
|
1092
|
-
to = '';
|
1093
|
-
else if (isX(tm))
|
1094
|
-
to = '<' + (+tM + 1) + '.0.0';
|
1095
|
-
else if (isX(tp))
|
1096
|
-
to = '<' + tM + '.' + (+tm + 1) + '.0';
|
1097
|
-
else if (tpr)
|
1098
|
-
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
|
1099
|
-
else
|
1100
|
-
to = '<=' + to;
|
1101
|
-
|
1102
|
-
return (from + ' ' + to).trim();
|
1103
|
-
}
|
1168
|
+
function hyphenReplace ($0,
|
1169
|
+
from, fM, fm, fp, fpr, fb,
|
1170
|
+
to, tM, tm, tp, tpr, tb) {
|
1171
|
+
if (isX(fM)) {
|
1172
|
+
from = ''
|
1173
|
+
} else if (isX(fm)) {
|
1174
|
+
from = '>=' + fM + '.0.0'
|
1175
|
+
} else if (isX(fp)) {
|
1176
|
+
from = '>=' + fM + '.' + fm + '.0'
|
1177
|
+
} else {
|
1178
|
+
from = '>=' + from
|
1179
|
+
}
|
1104
1180
|
|
1181
|
+
if (isX(tM)) {
|
1182
|
+
to = ''
|
1183
|
+
} else if (isX(tm)) {
|
1184
|
+
to = '<' + (+tM + 1) + '.0.0'
|
1185
|
+
} else if (isX(tp)) {
|
1186
|
+
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
1187
|
+
} else if (tpr) {
|
1188
|
+
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
1189
|
+
} else {
|
1190
|
+
to = '<=' + to
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
return (from + ' ' + to).trim()
|
1194
|
+
}
|
1105
1195
|
|
1106
1196
|
// if ANY of the sets match ALL of its comparators, then pass
|
1107
|
-
Range.prototype.test = function(version) {
|
1108
|
-
if (!version)
|
1109
|
-
return false
|
1197
|
+
Range.prototype.test = function (version) {
|
1198
|
+
if (!version) {
|
1199
|
+
return false
|
1200
|
+
}
|
1110
1201
|
|
1111
|
-
if (typeof version === 'string')
|
1112
|
-
version = new SemVer(version, this.
|
1202
|
+
if (typeof version === 'string') {
|
1203
|
+
version = new SemVer(version, this.options)
|
1204
|
+
}
|
1113
1205
|
|
1114
1206
|
for (var i = 0; i < this.set.length; i++) {
|
1115
|
-
if (testSet(this.set[i], version))
|
1116
|
-
return true
|
1207
|
+
if (testSet(this.set[i], version, this.options)) {
|
1208
|
+
return true
|
1209
|
+
}
|
1117
1210
|
}
|
1118
|
-
return false
|
1119
|
-
}
|
1211
|
+
return false
|
1212
|
+
}
|
1120
1213
|
|
1121
|
-
function testSet(set, version) {
|
1214
|
+
function testSet (set, version, options) {
|
1122
1215
|
for (var i = 0; i < set.length; i++) {
|
1123
|
-
if (!set[i].test(version))
|
1124
|
-
return false
|
1216
|
+
if (!set[i].test(version)) {
|
1217
|
+
return false
|
1218
|
+
}
|
1125
1219
|
}
|
1126
1220
|
|
1127
|
-
if (version.prerelease.length) {
|
1221
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
1128
1222
|
// Find the set of versions that are allowed to have prereleases
|
1129
1223
|
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
1130
1224
|
// That should allow `1.2.3-pr.2` to pass.
|
1131
1225
|
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
1132
1226
|
// even though it's within the range set by the comparators.
|
1133
|
-
for (
|
1134
|
-
debug(set[i].semver)
|
1135
|
-
if (set[i].semver === ANY)
|
1136
|
-
continue
|
1227
|
+
for (i = 0; i < set.length; i++) {
|
1228
|
+
debug(set[i].semver)
|
1229
|
+
if (set[i].semver === ANY) {
|
1230
|
+
continue
|
1231
|
+
}
|
1137
1232
|
|
1138
1233
|
if (set[i].semver.prerelease.length > 0) {
|
1139
|
-
var allowed = set[i].semver
|
1234
|
+
var allowed = set[i].semver
|
1140
1235
|
if (allowed.major === version.major &&
|
1141
1236
|
allowed.minor === version.minor &&
|
1142
|
-
allowed.patch === version.patch)
|
1143
|
-
return true
|
1237
|
+
allowed.patch === version.patch) {
|
1238
|
+
return true
|
1239
|
+
}
|
1144
1240
|
}
|
1145
1241
|
}
|
1146
1242
|
|
1147
1243
|
// Version has a -pre, but it's not one of the ones we like.
|
1148
|
-
return false
|
1244
|
+
return false
|
1149
1245
|
}
|
1150
1246
|
|
1151
|
-
return true
|
1247
|
+
return true
|
1152
1248
|
}
|
1153
1249
|
|
1154
|
-
exports.satisfies = satisfies
|
1155
|
-
function satisfies(version, range,
|
1250
|
+
exports.satisfies = satisfies
|
1251
|
+
function satisfies (version, range, options) {
|
1156
1252
|
try {
|
1157
|
-
range = new Range(range,
|
1253
|
+
range = new Range(range, options)
|
1158
1254
|
} catch (er) {
|
1159
|
-
return false
|
1255
|
+
return false
|
1160
1256
|
}
|
1161
|
-
return range.test(version)
|
1257
|
+
return range.test(version)
|
1162
1258
|
}
|
1163
1259
|
|
1164
|
-
exports.maxSatisfying = maxSatisfying
|
1165
|
-
function maxSatisfying(versions, range,
|
1166
|
-
var max = null
|
1167
|
-
var maxSV = null
|
1260
|
+
exports.maxSatisfying = maxSatisfying
|
1261
|
+
function maxSatisfying (versions, range, options) {
|
1262
|
+
var max = null
|
1263
|
+
var maxSV = null
|
1168
1264
|
try {
|
1169
|
-
var rangeObj = new Range(range,
|
1265
|
+
var rangeObj = new Range(range, options)
|
1170
1266
|
} catch (er) {
|
1171
|
-
return null
|
1267
|
+
return null
|
1172
1268
|
}
|
1173
1269
|
versions.forEach(function (v) {
|
1174
|
-
if (rangeObj.test(v)) {
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1270
|
+
if (rangeObj.test(v)) {
|
1271
|
+
// satisfies(v, range, options)
|
1272
|
+
if (!max || maxSV.compare(v) === -1) {
|
1273
|
+
// compare(max, v, true)
|
1274
|
+
max = v
|
1275
|
+
maxSV = new SemVer(max, options)
|
1178
1276
|
}
|
1179
1277
|
}
|
1180
1278
|
})
|
1181
|
-
return max
|
1279
|
+
return max
|
1182
1280
|
}
|
1183
1281
|
|
1184
|
-
exports.minSatisfying = minSatisfying
|
1185
|
-
function minSatisfying(versions, range,
|
1186
|
-
var min = null
|
1187
|
-
var minSV = null
|
1282
|
+
exports.minSatisfying = minSatisfying
|
1283
|
+
function minSatisfying (versions, range, options) {
|
1284
|
+
var min = null
|
1285
|
+
var minSV = null
|
1188
1286
|
try {
|
1189
|
-
var rangeObj = new Range(range,
|
1287
|
+
var rangeObj = new Range(range, options)
|
1190
1288
|
} catch (er) {
|
1191
|
-
return null
|
1289
|
+
return null
|
1192
1290
|
}
|
1193
1291
|
versions.forEach(function (v) {
|
1194
|
-
if (rangeObj.test(v)) {
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1292
|
+
if (rangeObj.test(v)) {
|
1293
|
+
// satisfies(v, range, options)
|
1294
|
+
if (!min || minSV.compare(v) === 1) {
|
1295
|
+
// compare(min, v, true)
|
1296
|
+
min = v
|
1297
|
+
minSV = new SemVer(min, options)
|
1198
1298
|
}
|
1199
1299
|
}
|
1200
1300
|
})
|
1201
|
-
return min
|
1301
|
+
return min
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
exports.minVersion = minVersion
|
1305
|
+
function minVersion (range, loose) {
|
1306
|
+
range = new Range(range, loose)
|
1307
|
+
|
1308
|
+
var minver = new SemVer('0.0.0')
|
1309
|
+
if (range.test(minver)) {
|
1310
|
+
return minver
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
minver = new SemVer('0.0.0-0')
|
1314
|
+
if (range.test(minver)) {
|
1315
|
+
return minver
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
minver = null
|
1319
|
+
for (var i = 0; i < range.set.length; ++i) {
|
1320
|
+
var comparators = range.set[i]
|
1321
|
+
|
1322
|
+
comparators.forEach(function (comparator) {
|
1323
|
+
// Clone to avoid manipulating the comparator's semver object.
|
1324
|
+
var compver = new SemVer(comparator.semver.version)
|
1325
|
+
switch (comparator.operator) {
|
1326
|
+
case '>':
|
1327
|
+
if (compver.prerelease.length === 0) {
|
1328
|
+
compver.patch++
|
1329
|
+
} else {
|
1330
|
+
compver.prerelease.push(0)
|
1331
|
+
}
|
1332
|
+
compver.raw = compver.format()
|
1333
|
+
/* fallthrough */
|
1334
|
+
case '':
|
1335
|
+
case '>=':
|
1336
|
+
if (!minver || gt(minver, compver)) {
|
1337
|
+
minver = compver
|
1338
|
+
}
|
1339
|
+
break
|
1340
|
+
case '<':
|
1341
|
+
case '<=':
|
1342
|
+
/* Ignore maximum versions */
|
1343
|
+
break
|
1344
|
+
/* istanbul ignore next */
|
1345
|
+
default:
|
1346
|
+
throw new Error('Unexpected operation: ' + comparator.operator)
|
1347
|
+
}
|
1348
|
+
})
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
if (minver && range.test(minver)) {
|
1352
|
+
return minver
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
return null
|
1202
1356
|
}
|
1203
1357
|
|
1204
|
-
exports.validRange = validRange
|
1205
|
-
function validRange(range,
|
1358
|
+
exports.validRange = validRange
|
1359
|
+
function validRange (range, options) {
|
1206
1360
|
try {
|
1207
1361
|
// Return '*' instead of '' so that truthiness works.
|
1208
1362
|
// This will throw if it's invalid anyway
|
1209
|
-
return new Range(range,
|
1363
|
+
return new Range(range, options).range || '*'
|
1210
1364
|
} catch (er) {
|
1211
|
-
return null
|
1365
|
+
return null
|
1212
1366
|
}
|
1213
1367
|
}
|
1214
1368
|
|
1215
1369
|
// Determine if version is less than all the versions possible in the range
|
1216
|
-
exports.ltr = ltr
|
1217
|
-
function ltr(version, range,
|
1218
|
-
return outside(version, range, '<',
|
1370
|
+
exports.ltr = ltr
|
1371
|
+
function ltr (version, range, options) {
|
1372
|
+
return outside(version, range, '<', options)
|
1219
1373
|
}
|
1220
1374
|
|
1221
1375
|
// Determine if version is greater than all the versions possible in the range.
|
1222
|
-
exports.gtr = gtr
|
1223
|
-
function gtr(version, range,
|
1224
|
-
return outside(version, range, '>',
|
1376
|
+
exports.gtr = gtr
|
1377
|
+
function gtr (version, range, options) {
|
1378
|
+
return outside(version, range, '>', options)
|
1225
1379
|
}
|
1226
1380
|
|
1227
|
-
exports.outside = outside
|
1228
|
-
function outside(version, range, hilo,
|
1229
|
-
version = new SemVer(version,
|
1230
|
-
range = new Range(range,
|
1381
|
+
exports.outside = outside
|
1382
|
+
function outside (version, range, hilo, options) {
|
1383
|
+
version = new SemVer(version, options)
|
1384
|
+
range = new Range(range, options)
|
1231
1385
|
|
1232
|
-
var gtfn, ltefn, ltfn, comp, ecomp
|
1386
|
+
var gtfn, ltefn, ltfn, comp, ecomp
|
1233
1387
|
switch (hilo) {
|
1234
1388
|
case '>':
|
1235
|
-
gtfn = gt
|
1236
|
-
ltefn = lte
|
1237
|
-
ltfn = lt
|
1238
|
-
comp = '>'
|
1239
|
-
ecomp = '>='
|
1240
|
-
break
|
1389
|
+
gtfn = gt
|
1390
|
+
ltefn = lte
|
1391
|
+
ltfn = lt
|
1392
|
+
comp = '>'
|
1393
|
+
ecomp = '>='
|
1394
|
+
break
|
1241
1395
|
case '<':
|
1242
|
-
gtfn = lt
|
1243
|
-
ltefn = gte
|
1244
|
-
ltfn = gt
|
1245
|
-
comp = '<'
|
1246
|
-
ecomp = '<='
|
1247
|
-
break
|
1396
|
+
gtfn = lt
|
1397
|
+
ltefn = gte
|
1398
|
+
ltfn = gt
|
1399
|
+
comp = '<'
|
1400
|
+
ecomp = '<='
|
1401
|
+
break
|
1248
1402
|
default:
|
1249
|
-
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
1403
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
1250
1404
|
}
|
1251
1405
|
|
1252
1406
|
// If it satisifes the range it is not outside
|
1253
|
-
if (satisfies(version, range,
|
1254
|
-
return false
|
1407
|
+
if (satisfies(version, range, options)) {
|
1408
|
+
return false
|
1255
1409
|
}
|
1256
1410
|
|
1257
1411
|
// From now on, variable terms are as if we're in "gtr" mode.
|
1258
1412
|
// but note that everything is flipped for the "ltr" function.
|
1259
1413
|
|
1260
1414
|
for (var i = 0; i < range.set.length; ++i) {
|
1261
|
-
var comparators = range.set[i]
|
1415
|
+
var comparators = range.set[i]
|
1262
1416
|
|
1263
|
-
var high = null
|
1264
|
-
var low = null
|
1417
|
+
var high = null
|
1418
|
+
var low = null
|
1265
1419
|
|
1266
|
-
comparators.forEach(function(comparator) {
|
1420
|
+
comparators.forEach(function (comparator) {
|
1267
1421
|
if (comparator.semver === ANY) {
|
1268
1422
|
comparator = new Comparator('>=0.0.0')
|
1269
1423
|
}
|
1270
|
-
high = high || comparator
|
1271
|
-
low = low || comparator
|
1272
|
-
if (gtfn(comparator.semver, high.semver,
|
1273
|
-
high = comparator
|
1274
|
-
} else if (ltfn(comparator.semver, low.semver,
|
1275
|
-
low = comparator
|
1424
|
+
high = high || comparator
|
1425
|
+
low = low || comparator
|
1426
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
1427
|
+
high = comparator
|
1428
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
1429
|
+
low = comparator
|
1276
1430
|
}
|
1277
|
-
})
|
1431
|
+
})
|
1278
1432
|
|
1279
1433
|
// If the edge version comparator has a operator then our version
|
1280
1434
|
// isn't outside it
|
1281
1435
|
if (high.operator === comp || high.operator === ecomp) {
|
1282
|
-
return false
|
1436
|
+
return false
|
1283
1437
|
}
|
1284
1438
|
|
1285
1439
|
// If the lowest version comparator has an operator and our version
|
1286
1440
|
// is less than it then it isn't higher than the range
|
1287
1441
|
if ((!low.operator || low.operator === comp) &&
|
1288
1442
|
ltefn(version, low.semver)) {
|
1289
|
-
return false
|
1443
|
+
return false
|
1290
1444
|
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
1291
|
-
return false
|
1445
|
+
return false
|
1292
1446
|
}
|
1293
1447
|
}
|
1294
|
-
return true
|
1448
|
+
return true
|
1295
1449
|
}
|
1296
1450
|
|
1297
|
-
exports.prerelease = prerelease
|
1298
|
-
function prerelease(version,
|
1299
|
-
var parsed = parse(version,
|
1300
|
-
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
1451
|
+
exports.prerelease = prerelease
|
1452
|
+
function prerelease (version, options) {
|
1453
|
+
var parsed = parse(version, options)
|
1454
|
+
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
1301
1455
|
}
|
1302
1456
|
|
1303
|
-
exports.intersects = intersects
|
1304
|
-
function intersects(r1, r2,
|
1305
|
-
r1 = new Range(r1,
|
1306
|
-
r2 = new Range(r2,
|
1457
|
+
exports.intersects = intersects
|
1458
|
+
function intersects (r1, r2, options) {
|
1459
|
+
r1 = new Range(r1, options)
|
1460
|
+
r2 = new Range(r2, options)
|
1307
1461
|
return r1.intersects(r2)
|
1308
1462
|
}
|
1309
1463
|
|
1310
|
-
exports.coerce = coerce
|
1311
|
-
function coerce(version) {
|
1312
|
-
if (version instanceof SemVer)
|
1313
|
-
return version
|
1464
|
+
exports.coerce = coerce
|
1465
|
+
function coerce (version) {
|
1466
|
+
if (version instanceof SemVer) {
|
1467
|
+
return version
|
1468
|
+
}
|
1314
1469
|
|
1315
|
-
if (typeof version !== 'string')
|
1316
|
-
return null
|
1470
|
+
if (typeof version !== 'string') {
|
1471
|
+
return null
|
1472
|
+
}
|
1317
1473
|
|
1318
|
-
var match = version.match(re[COERCE])
|
1474
|
+
var match = version.match(re[COERCE])
|
1319
1475
|
|
1320
|
-
if (match == null)
|
1321
|
-
return null
|
1476
|
+
if (match == null) {
|
1477
|
+
return null
|
1478
|
+
}
|
1322
1479
|
|
1323
|
-
return parse(
|
1480
|
+
return parse(match[1] +
|
1481
|
+
'.' + (match[2] || '0') +
|
1482
|
+
'.' + (match[3] || '0'))
|
1324
1483
|
}
|