public
Created

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

  • Download Gist
rangecheck.js
JavaScript
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'))

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

also note:

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

in reference to yahoo/mojito/pull/498

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.

example

% semver -v 0.6.0 -r '>0.6''
0.6.0  #ok

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.