Comparing version 1.0.10 to 1.0.11
{ "name" : "semver" | ||
, "version" : "1.0.10" | ||
, "version" : "1.0.11" | ||
, "description" : "The semantic version parser used by npm." | ||
, "main" : "semver.js" | ||
, "scripts" : { "test" : "tap semver.js" } | ||
, "scripts" : { "test" : "tap test.js" } | ||
, "devDependencies": { "tap" : "0.x >=0.0.4" } | ||
@@ -7,0 +7,0 @@ , "license" : |
264
semver.js
@@ -51,2 +51,5 @@ | ||
exports.replaceStars = replaceStars | ||
exports.toComparators = toComparators | ||
function stringify (version) { | ||
@@ -111,7 +114,7 @@ var v = version | ||
function replaceStars (stars) { | ||
return stars.replace(starExpression, starReplace) | ||
return stars.trim().replace(starExpression, starReplace) | ||
} | ||
// "2.x","2.x.x" --> ">=2.0.0 <2.1" | ||
// "2.3.x" --> ">=2.3.0 <2.4.0" | ||
// "2.x","2.x.x" --> ">=2.0.0- <2.1.0-" | ||
// "2.3.x" --> ">=2.3.0- <2.4.0-" | ||
function replaceXRanges (ranges) { | ||
@@ -163,15 +166,16 @@ return ranges.split(/\s+/) | ||
"Using '"+gtlt+"' with ~ makes no sense. Don't do it.") | ||
if (!M || M.toLowerCase() === "x") { | ||
return "*" | ||
return "" | ||
} | ||
// ~1 == >=1.0.0 <2.0.0 | ||
// ~1 == >=1.0.0- <2.0.0- | ||
if (!m || m.toLowerCase() === "x") { | ||
return ">="+M+".0.0 <"+(+M+1)+".0.0" | ||
return ">="+M+".0.0- <"+(+M+1)+".0.0-" | ||
} | ||
// ~1.2 == >=1.2.0 <1.3.0 | ||
// ~1.2 == >=1.2.0- <1.3.0- | ||
if (!p || p.toLowerCase() === "x") { | ||
return ">="+M+"."+m+".0 <"+M+"."+(+m+1)+".0" | ||
return ">="+M+"."+m+".0- <"+M+"."+(+m+1)+".0-" | ||
} | ||
// ~1.2.3 == >=1.2.3 <1.3.0 | ||
return ">="+M+"."+m+"."+p+" <"+M+"."+(+m+1)+".0" | ||
// ~1.2.3 == >=1.2.3- <1.3.0- | ||
return ">="+M+"."+m+"."+p+"- <"+M+"."+(+m+1)+".0-" | ||
}) | ||
@@ -181,3 +185,3 @@ } | ||
function validRange (range) { | ||
range = range.trim().replace(starExpression, starReplace) | ||
range = replaceStars(range) | ||
var c = toComparators(range) | ||
@@ -301,239 +305,1 @@ return (c.length === 0) | ||
if (module === require.main) { // tests below | ||
var tap = require("tap") | ||
, test = tap.test | ||
tap.plan(5) | ||
test("\ncomparison tests", function (t) { | ||
; [ ["0.0.0", "0.0.0foo"] | ||
, ["0.0.1", "0.0.0"] | ||
, ["1.0.0", "0.9.9"] | ||
, ["0.10.0", "0.9.0"] | ||
, ["0.99.0", "0.10.0"] | ||
, ["2.0.0", "1.2.3"] | ||
, ["v0.0.0", "0.0.0foo"] | ||
, ["v0.0.1", "0.0.0"] | ||
, ["v1.0.0", "0.9.9"] | ||
, ["v0.10.0", "0.9.0"] | ||
, ["v0.99.0", "0.10.0"] | ||
, ["v2.0.0", "1.2.3"] | ||
, ["0.0.0", "v0.0.0foo"] | ||
, ["0.0.1", "v0.0.0"] | ||
, ["1.0.0", "v0.9.9"] | ||
, ["0.10.0", "v0.9.0"] | ||
, ["0.99.0", "v0.10.0"] | ||
, ["2.0.0", "v1.2.3"] | ||
, ["1.2.3", "1.2.3-asdf"] | ||
, ["1.2.3-4", "1.2.3"] | ||
, ["1.2.3-4-foo", "1.2.3"] | ||
, ["1.2.3-5", "1.2.3-5-foo"] | ||
, ["1.2.3-5", "1.2.3-4"] | ||
, ["1.2.3-5-foo", "1.2.3-5-Foo"] | ||
].forEach(function (v) { | ||
var v0 = v[0] | ||
, v1 = v[1] | ||
t.ok(gt(v0, v1), "gt('"+v0+"', '"+v1+"')") | ||
t.ok(lt(v1, v0), "lt('"+v1+"', '"+v0+"')") | ||
t.ok(!gt(v1, v0), "!gt('"+v1+"', '"+v0+"')") | ||
t.ok(!lt(v0, v1), "!lt('"+v0+"', '"+v1+"')") | ||
t.ok(eq(v0, v0), "eq('"+v0+"', '"+v0+"')") | ||
t.ok(eq(v1, v1), "eq('"+v1+"', '"+v1+"')") | ||
t.ok(neq(v0, v1), "neq('"+v0+"', '"+v1+"')") | ||
t.ok(cmp(v1, "==", v1), "cmp('"+v1+"' == '"+v1+"')") | ||
t.ok(cmp(v0, ">=", v1), "cmp('"+v0+"' >= '"+v1+"')") | ||
t.ok(cmp(v1, "<=", v0), "cmp('"+v1+"' <= '"+v0+"')") | ||
t.ok(cmp(v0, "!=", v1), "cmp('"+v0+"' != '"+v1+"')") | ||
}) | ||
t.end() | ||
}) | ||
test("\nequality tests", function (t) { | ||
; [ ["1.2.3", "v1.2.3"] | ||
, ["1.2.3", "=1.2.3"] | ||
, ["1.2.3", "v 1.2.3"] | ||
, ["1.2.3", "= 1.2.3"] | ||
, ["1.2.3", " v1.2.3"] | ||
, ["1.2.3", " =1.2.3"] | ||
, ["1.2.3", " v 1.2.3"] | ||
, ["1.2.3", " = 1.2.3"] | ||
, ["1.2.3-0", "v1.2.3-0"] | ||
, ["1.2.3-0", "=1.2.3-0"] | ||
, ["1.2.3-0", "v 1.2.3-0"] | ||
, ["1.2.3-0", "= 1.2.3-0"] | ||
, ["1.2.3-0", " v1.2.3-0"] | ||
, ["1.2.3-0", " =1.2.3-0"] | ||
, ["1.2.3-0", " v 1.2.3-0"] | ||
, ["1.2.3-0", " = 1.2.3-0"] | ||
, ["1.2.3-01", "v1.2.3-1"] | ||
, ["1.2.3-01", "=1.2.3-1"] | ||
, ["1.2.3-01", "v 1.2.3-1"] | ||
, ["1.2.3-01", "= 1.2.3-1"] | ||
, ["1.2.3-01", " v1.2.3-1"] | ||
, ["1.2.3-01", " =1.2.3-1"] | ||
, ["1.2.3-01", " v 1.2.3-1"] | ||
, ["1.2.3-01", " = 1.2.3-1"] | ||
, ["1.2.3beta", "v1.2.3beta"] | ||
, ["1.2.3beta", "=1.2.3beta"] | ||
, ["1.2.3beta", "v 1.2.3beta"] | ||
, ["1.2.3beta", "= 1.2.3beta"] | ||
, ["1.2.3beta", " v1.2.3beta"] | ||
, ["1.2.3beta", " =1.2.3beta"] | ||
, ["1.2.3beta", " v 1.2.3beta"] | ||
, ["1.2.3beta", " = 1.2.3beta"] | ||
].forEach(function (v) { | ||
var v0 = v[0] | ||
, v1 = v[1] | ||
t.ok(eq(v0, v1), "eq('"+v0+"', '"+v1+"')") | ||
t.ok(!neq(v0, v1), "!neq('"+v0+"', '"+v1+"')") | ||
t.ok(cmp(v0, "==", v1), "cmp("+v0+"=="+v1+")") | ||
t.ok(!cmp(v0, "!=", v1), "!cmp("+v0+"!="+v1+")") | ||
t.ok(!cmp(v0, "===", v1), "!cmp("+v0+"==="+v1+")") | ||
t.ok(cmp(v0, "!==", v1), "cmp("+v0+"!=="+v1+")") | ||
t.ok(!gt(v0, v1), "!gt('"+v0+"', '"+v1+"')") | ||
t.ok(gte(v0, v1), "gte('"+v0+"', '"+v1+"')") | ||
t.ok(!lt(v0, v1), "!lt('"+v0+"', '"+v1+"')") | ||
t.ok(lte(v0, v1), "lte('"+v0+"', '"+v1+"')") | ||
}) | ||
t.end() | ||
}) | ||
test("\nrange tests", function (t) { | ||
; [ ["1.0.0 - 2.0.0", "1.2.3"] | ||
, ["1.0.0", "1.0.0"] | ||
, [">=*", "0.2.4"] | ||
, ["", "1.0.0"] | ||
, ["*", "1.2.3"] | ||
, ["*", "v1.2.3-foo"] | ||
, [">=1.0.0", "1.0.0"] | ||
, [">=1.0.0", "1.0.1"] | ||
, [">=1.0.0", "1.1.0"] | ||
, [">1.0.0", "1.0.1"] | ||
, [">1.0.0", "1.1.0"] | ||
, ["<=2.0.0", "2.0.0"] | ||
, ["<=2.0.0", "1.9999.9999"] | ||
, ["<=2.0.0", "0.2.9"] | ||
, ["<2.0.0", "1.9999.9999"] | ||
, ["<2.0.0", "0.2.9"] | ||
, [">= 1.0.0", "1.0.0"] | ||
, [">= 1.0.0", "1.0.1"] | ||
, [">= 1.0.0", "1.1.0"] | ||
, ["> 1.0.0", "1.0.1"] | ||
, ["> 1.0.0", "1.1.0"] | ||
, ["<= 2.0.0", "2.0.0"] | ||
, ["<= 2.0.0", "1.9999.9999"] | ||
, ["<= 2.0.0", "0.2.9"] | ||
, ["< 2.0.0", "1.9999.9999"] | ||
, ["<\t2.0.0", "0.2.9"] | ||
, [">=0.1.97", "v0.1.97"] | ||
, [">=0.1.97", "0.1.97"] | ||
, ["0.1.20 || 1.2.4", "1.2.4"] | ||
, [">=0.2.3 || <0.0.1", "0.0.0"] | ||
, [">=0.2.3 || <0.0.1", "0.2.3"] | ||
, [">=0.2.3 || <0.0.1", "0.2.4"] | ||
, ["||", "1.3.4"] | ||
, ["2.x.x", "2.1.3"] | ||
, ["1.2.x", "1.2.3"] | ||
, ["1.2.x || 2.x", "2.1.3"] | ||
, ["1.2.x || 2.x", "1.2.3"] | ||
, ["x", "1.2.3"] | ||
, ["2.*.*", "2.1.3"] | ||
, ["1.2.*", "1.2.3"] | ||
, ["1.2.* || 2.*", "2.1.3"] | ||
, ["1.2.* || 2.*", "1.2.3"] | ||
, ["*", "1.2.3"] | ||
, ["2", "2.1.2"] | ||
, ["2.3", "2.3.1"] | ||
, ["~2.4", "2.4.0"] // >=2.4.0 <2.5.0 | ||
, ["~2.4", "2.4.5"] | ||
, ["~>3.2.1", "3.2.2"] // >=3.2.1 <3.3.0 | ||
, ["~1", "1.2.3"] // >=1.0.0 <2.0.0 | ||
, ["~>1", "1.2.3"] | ||
, ["~> 1", "1.2.3"] | ||
, ["~1.0", "1.0.2"] // >=1.0.0 <1.1.0 | ||
, ["~ 1.0", "1.0.2"] | ||
, ["<1", "1.0.0beta"] | ||
, ["< 1", "1.0.0beta"] | ||
, [">=1", "1.0.0"] | ||
, [">= 1", "1.0.0"] | ||
, ["<1.2", "1.1.1"] | ||
, ["< 1.2", "1.1.1"] | ||
, ["1", "1.0.0beta"] | ||
].forEach(function (v) { | ||
t.ok(satisfies(v[1], v[0]), v[0]+" satisfied by "+v[1]) | ||
}) | ||
t.end() | ||
}) | ||
test("\nnegative range tests", function (t) { | ||
; [ ["1.0.0 - 2.0.0", "2.2.3"] | ||
, ["1.0.0", "1.0.1"] | ||
, [">=1.0.0", "0.0.0"] | ||
, [">=1.0.0", "0.0.1"] | ||
, [">=1.0.0", "0.1.0"] | ||
, [">1.0.0", "0.0.1"] | ||
, [">1.0.0", "0.1.0"] | ||
, ["<=2.0.0", "3.0.0"] | ||
, ["<=2.0.0", "2.9999.9999"] | ||
, ["<=2.0.0", "2.2.9"] | ||
, ["<2.0.0", "2.9999.9999"] | ||
, ["<2.0.0", "2.2.9"] | ||
, [">=0.1.97", "v0.1.93"] | ||
, [">=0.1.97", "0.1.93"] | ||
, ["0.1.20 || 1.2.4", "1.2.3"] | ||
, [">=0.2.3 || <0.0.1", "0.0.3"] | ||
, [">=0.2.3 || <0.0.1", "0.2.2"] | ||
, ["2.x.x", "1.1.3"] | ||
, ["2.x.x", "3.1.3"] | ||
, ["1.2.x", "1.3.3"] | ||
, ["1.2.x || 2.x", "3.1.3"] | ||
, ["1.2.x || 2.x", "1.1.3"] | ||
, ["2.*.*", "1.1.3"] | ||
, ["2.*.*", "3.1.3"] | ||
, ["1.2.*", "1.3.3"] | ||
, ["1.2.* || 2.*", "3.1.3"] | ||
, ["1.2.* || 2.*", "1.1.3"] | ||
, ["2", "1.1.2"] | ||
, ["2.3", "2.4.1"] | ||
, ["~2.4", "2.5.0"] // >=2.4.0 <2.5.0 | ||
, ["~2.4", "2.3.9"] | ||
, ["~>3.2.1", "3.3.2"] // >=3.2.1 <3.3.0 | ||
, ["~>3.2.1", "3.2.0"] // >=3.2.1 <3.3.0 | ||
, ["~1", "0.2.3"] // >=1.0.0 <2.0.0 | ||
, ["~>1", "2.2.3"] | ||
, ["~1.0", "1.1.0"] // >=1.0.0 <1.1.0 | ||
, ["<1", "1.0.0"] | ||
, [">=1.2", "1.1.1"] | ||
, ["1", "2.0.0beta"] | ||
].forEach(function (v) { | ||
t.ok(!satisfies(v[1], v[0]), v[0]+" not satisfied by "+v[1]) | ||
}) | ||
t.end() | ||
}) | ||
test("\nincrement versions test", function (t) { | ||
; [ [ "1.2.3", "major", "2.0.0" ] | ||
, [ "1.2.3", "minor", "1.3.0" ] | ||
, [ "1.2.3", "patch", "1.2.4" ] | ||
, [ "1.2.3", "build", "1.2.3-1" ] | ||
, [ "1.2.3-4", "build", "1.2.3-5" ] | ||
, [ "1.2.3tag", "major", "2.0.0" ] | ||
, [ "1.2.3-tag", "major", "2.0.0" ] | ||
, [ "1.2.3tag", "build", "1.2.3-1" ] | ||
, [ "1.2.3-tag", "build", "1.2.3-1" ] | ||
, [ "1.2.3-4-tag", "build", "1.2.3-5" ] | ||
, [ "1.2.3-4tag", "build", "1.2.3-5" ] | ||
, [ "1.2.3", "fake", null ] | ||
, [ "fake", "major", null ] | ||
].forEach(function (v) { | ||
t.equal(inc(v[0], v[1]), v[2], "inc("+v[0]+", "+v[1]+") === "+v[2]) | ||
}) | ||
t.end() | ||
}) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
27930
650
1
6