semver 1.1.0 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/semver +1 -0
- package/package.json +1 -1
- package/semver.js +4 -3
- package/test.js +30 -0
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@ semver(1) -- The semantic versioner for npm
|
|
|
5
5
|
|
|
6
6
|
$ npm install semver
|
|
7
7
|
|
|
8
|
-
semver.valid('1.2.3') //
|
|
9
|
-
semver.valid('a.b.c') //
|
|
8
|
+
semver.valid('1.2.3') // '1.2.3'
|
|
9
|
+
semver.valid('a.b.c') // null
|
|
10
10
|
semver.clean(' =v1.2.3 ') // '1.2.3'
|
|
11
11
|
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
|
12
12
|
semver.gt('1.2.3', '9.8.7') // false
|
|
@@ -76,7 +76,7 @@ The following range styles are supported:
|
|
|
76
76
|
* `<1.2.3` Less than
|
|
77
77
|
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
|
78
78
|
* `~1.2.3` := `>=1.2.3 <1.3.0`
|
|
79
|
-
* `~1.2` := `>=1.2.0 <
|
|
79
|
+
* `~1.2` := `>=1.2.0 <1.3.0`
|
|
80
80
|
* `~1` := `>=1.0.0 <2.0.0`
|
|
81
81
|
* `1.2.x` := `>=1.2.0 <1.3.0`
|
|
82
82
|
* `1.x` := `>=1.0.0 <2.0.0`
|
package/bin/semver
CHANGED
package/package.json
CHANGED
package/semver.js
CHANGED
|
@@ -15,7 +15,8 @@ var semver = "\\s*[v=]*\\s*([0-9]+)" // major
|
|
|
15
15
|
+ "(?:\\.([0-9]+|x|X|\\*)"
|
|
16
16
|
+ "([a-zA-Z-][a-zA-Z0-9-\.:]*)?)?)?"
|
|
17
17
|
, xRange = "((?:<|>)=?)?\\s*" + xRangePlain
|
|
18
|
-
,
|
|
18
|
+
, exprLoneSpermy = "(?:~>?)"
|
|
19
|
+
, exprSpermy = exprLoneSpermy + xRange
|
|
19
20
|
, expressions = exports.expressions =
|
|
20
21
|
{ parse : new RegExp("^\\s*"+semver+"\\s*$")
|
|
21
22
|
, parsePackage : new RegExp("^\\s*([^\/]+)[-@](" +semver+")\\s*$")
|
|
@@ -84,7 +85,7 @@ function validPackage (version) {
|
|
|
84
85
|
// ">1.0.2 <2.0.0" like 1.0.3 - 1.9999.9999
|
|
85
86
|
var starExpression = /(<|>)?=?\s*\*/g
|
|
86
87
|
, starReplace = ""
|
|
87
|
-
, compTrimExpression = new RegExp("((<|>)
|
|
88
|
+
, compTrimExpression = new RegExp("((<|>)?=|<|>)\\s*("
|
|
88
89
|
+semver+"|"+xRangePlain+")", "g")
|
|
89
90
|
, compTrimReplace = "$1$3"
|
|
90
91
|
|
|
@@ -97,6 +98,7 @@ function toComparators (range) {
|
|
|
97
98
|
.split("||")
|
|
98
99
|
.map(function (orchunk) {
|
|
99
100
|
return orchunk
|
|
101
|
+
.replace(new RegExp("(" + exprLoneSpermy + ")\\s+"), "$1")
|
|
100
102
|
.split(" ")
|
|
101
103
|
.map(replaceXRanges)
|
|
102
104
|
.map(replaceSpermies)
|
|
@@ -149,7 +151,6 @@ function replaceXRange (version) {
|
|
|
149
151
|
} else if (!p || p === "*" || p.toLowerCase() === "x") {
|
|
150
152
|
ret = ">="+M+"."+m+".0- <"+M+"."+(+m+1)+".0-"
|
|
151
153
|
}
|
|
152
|
-
//console.error("parseXRange", [].slice.call(arguments), ret)
|
|
153
154
|
return ret
|
|
154
155
|
})
|
|
155
156
|
}
|
package/test.js
CHANGED
|
@@ -17,6 +17,8 @@ var tap = require("tap")
|
|
|
17
17
|
tap.plan(8)
|
|
18
18
|
|
|
19
19
|
test("\ncomparison tests", function (t) {
|
|
20
|
+
// [version1, version2]
|
|
21
|
+
// version1 should be greater than version2
|
|
20
22
|
; [ ["0.0.0", "0.0.0foo"]
|
|
21
23
|
, ["0.0.1", "0.0.0"]
|
|
22
24
|
, ["1.0.0", "0.9.9"]
|
|
@@ -61,6 +63,8 @@ test("\ncomparison tests", function (t) {
|
|
|
61
63
|
})
|
|
62
64
|
|
|
63
65
|
test("\nequality tests", function (t) {
|
|
66
|
+
// [version1, version2]
|
|
67
|
+
// version1 should be equivalent to version2
|
|
64
68
|
; [ ["1.2.3", "v1.2.3"]
|
|
65
69
|
, ["1.2.3", "=1.2.3"]
|
|
66
70
|
, ["1.2.3", "v 1.2.3"]
|
|
@@ -112,6 +116,8 @@ test("\nequality tests", function (t) {
|
|
|
112
116
|
|
|
113
117
|
|
|
114
118
|
test("\nrange tests", function (t) {
|
|
119
|
+
// [range, version]
|
|
120
|
+
// version should be included by range
|
|
115
121
|
; [ ["1.0.0 - 2.0.0", "1.2.3"]
|
|
116
122
|
, ["1.0.0", "1.0.0"]
|
|
117
123
|
, [">=*", "0.2.4"]
|
|
@@ -165,6 +171,7 @@ test("\nrange tests", function (t) {
|
|
|
165
171
|
, ["~> 1", "1.2.3"]
|
|
166
172
|
, ["~1.0", "1.0.2"] // >=1.0.0 <1.1.0
|
|
167
173
|
, ["~ 1.0", "1.0.2"]
|
|
174
|
+
, ["~ 1.0.3", "1.0.12"]
|
|
168
175
|
, [">=1", "1.0.0"]
|
|
169
176
|
, [">= 1", "1.0.0"]
|
|
170
177
|
, ["<1.2", "1.1.1"]
|
|
@@ -177,6 +184,16 @@ test("\nrange tests", function (t) {
|
|
|
177
184
|
, ["=0.7.x", "0.7.0-asdf"]
|
|
178
185
|
, [">=0.7.x", "0.7.0-asdf"]
|
|
179
186
|
, ["<=0.7.x", "0.6.2"]
|
|
187
|
+
, ["~1.2.1 >=1.2.3", "1.2.3"]
|
|
188
|
+
, ["~1.2.1 =1.2.3", "1.2.3"]
|
|
189
|
+
, ["~1.2.1 1.2.3", "1.2.3"]
|
|
190
|
+
, ['~1.2.1 >=1.2.3 1.2.3', '1.2.3']
|
|
191
|
+
, ['~1.2.1 1.2.3 >=1.2.3', '1.2.3']
|
|
192
|
+
, ['~1.2.1 1.2.3', '1.2.3']
|
|
193
|
+
, ['>=1.2.1 1.2.3', '1.2.3']
|
|
194
|
+
, ['1.2.3 >=1.2.1', '1.2.3']
|
|
195
|
+
, ['>=1.2.3 >=1.2.1', '1.2.3']
|
|
196
|
+
, ['>=1.2.1 >=1.2.3', '1.2.3']
|
|
180
197
|
].forEach(function (v) {
|
|
181
198
|
t.ok(satisfies(v[1], v[0]), v[0]+" satisfied by "+v[1])
|
|
182
199
|
})
|
|
@@ -184,6 +201,8 @@ test("\nrange tests", function (t) {
|
|
|
184
201
|
})
|
|
185
202
|
|
|
186
203
|
test("\nnegative range tests", function (t) {
|
|
204
|
+
// [range, version]
|
|
205
|
+
// version should not be included by range
|
|
187
206
|
; [ ["1.0.0 - 2.0.0", "2.2.3"]
|
|
188
207
|
, ["1.0.0", "1.0.1"]
|
|
189
208
|
, [">=1.0.0", "0.0.0"]
|
|
@@ -236,6 +255,8 @@ test("\nnegative range tests", function (t) {
|
|
|
236
255
|
})
|
|
237
256
|
|
|
238
257
|
test("\nincrement versions test", function (t) {
|
|
258
|
+
// [version, inc, result]
|
|
259
|
+
// inc(version, inc) -> result
|
|
239
260
|
; [ [ "1.2.3", "major", "2.0.0" ]
|
|
240
261
|
, [ "1.2.3", "minor", "1.3.0" ]
|
|
241
262
|
, [ "1.2.3", "patch", "1.2.4" ]
|
|
@@ -257,6 +278,7 @@ test("\nincrement versions test", function (t) {
|
|
|
257
278
|
})
|
|
258
279
|
|
|
259
280
|
test("\nreplace stars test", function (t) {
|
|
281
|
+
// replace stars with ""
|
|
260
282
|
; [ [ "", "" ]
|
|
261
283
|
, [ "*", "" ]
|
|
262
284
|
, [ "> *", "" ]
|
|
@@ -271,6 +293,9 @@ test("\nreplace stars test", function (t) {
|
|
|
271
293
|
})
|
|
272
294
|
|
|
273
295
|
test("\nvalid range test", function (t) {
|
|
296
|
+
// [range, result]
|
|
297
|
+
// validRange(range) -> result
|
|
298
|
+
// translate ranges into their canonical form
|
|
274
299
|
; [ ["1.0.0 - 2.0.0", ">=1.0.0 <=2.0.0"]
|
|
275
300
|
, ["1.0.0", "1.0.0"]
|
|
276
301
|
, [">=*", ""]
|
|
@@ -337,6 +362,8 @@ test("\nvalid range test", function (t) {
|
|
|
337
362
|
})
|
|
338
363
|
|
|
339
364
|
test("\ncomparators test", function (t) {
|
|
365
|
+
// [range, comparators]
|
|
366
|
+
// turn range into a set of individual comparators
|
|
340
367
|
; [ ["1.0.0 - 2.0.0", [[">=1.0.0", "<=2.0.0"]] ]
|
|
341
368
|
, ["1.0.0", [["1.0.0"]] ]
|
|
342
369
|
, [">=*", [[">=0.0.0-"]] ]
|
|
@@ -391,6 +418,8 @@ test("\ncomparators test", function (t) {
|
|
|
391
418
|
, ["~> 1", [[">=1.0.0-", "<2.0.0-"]] ]
|
|
392
419
|
, ["~1.0", [[">=1.0.0-", "<1.1.0-"]] ]
|
|
393
420
|
, ["~ 1.0", [[">=1.0.0-", "<1.1.0-"]] ]
|
|
421
|
+
, ["~ 1.0.3", [[">=1.0.3-", "<1.1.0-"]] ]
|
|
422
|
+
, ["~> 1.0.3", [[">=1.0.3-", "<1.1.0-"]] ]
|
|
394
423
|
, ["<1", [["<1.0.0-"]] ]
|
|
395
424
|
, ["< 1", [["<1.0.0-"]] ]
|
|
396
425
|
, [">=1", [[">=1.0.0-"]] ]
|
|
@@ -398,6 +427,7 @@ test("\ncomparators test", function (t) {
|
|
|
398
427
|
, ["<1.2", [["<1.2.0-"]] ]
|
|
399
428
|
, ["< 1.2", [["<1.2.0-"]] ]
|
|
400
429
|
, ["1", [[">=1.0.0-", "<2.0.0-"]] ]
|
|
430
|
+
, ["1 2", [[">=1.0.0-", "<2.0.0-", ">=2.0.0-", "<3.0.0-"]] ]
|
|
401
431
|
].forEach(function (v) {
|
|
402
432
|
t.equivalent(toComparators(v[0]), v[1], "toComparators("+v[0]+") === "+JSON.stringify(v[1]))
|
|
403
433
|
})
|