Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

manually check semver's handling of '>x.x' style ranges

View rangecheck.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
var semver = require('semver')
 
function gettest(range) {
return function(version) {
var isok = semver.satisfies(version, range) ? 'is' : 'is not'
console.log('v%s %s supported for range %s', version, isok, range)
}
}
 
['0.2.0',
'0.3.9',
'0.4',
'0.3.9',
'0.4.0',
'0.4.9',
'0.5.0',
'0.6.0',
'0.8.0',
'0.8.8',
'0.9.0'].forEach(gettest('>0.4'));
 
['1.0.0',
'1.0.1',
'1.1.29'].forEach(gettest('>1.0'))
Owner

v0.2.0 is not supported for range >0.4
v0.3.9 is not supported for range >0.4
v0.4 is not supported for range >0.4
v0.3.9 is not supported for range >0.4
v0.4.0 is supported for range >0.4
v0.4.9 is supported for range >0.4
v0.5.0 is supported for range >0.4
v0.6.0 is supported for range >0.4
v0.8.0 is supported for range >0.4
v0.8.8 is supported for range >0.4
v0.9.0 is supported for range >0.4
v1.0.0 is supported for range >1.0
v1.0.1 is supported for range >1.0
v1.1.29 is supported for range >1.0

Owner

also note:

semver.valid('0.4');//null
semver.valid('0.5')//null
Owner

in reference to yahoo/mojito/pull/498

Owner

Ah, semver has it's own cli. This script is kinda redundant

Usage: semver -v [-r ]
Test if version(s) satisfy the supplied range(s),
and sort them.

Multiple versions or ranges may be supplied.

Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.

If no versions are valid, or ranges are not satisfied,
then exits failure.

Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.

Owner

example

% semver -v 0.6.0 -r '>0.6''
0.6.0  #ok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.