Create a gist now

Instantly share code, notes, and snippets.

manually check semver's handling of '>x.x' style ranges
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'))
@isao
Owner
isao commented Sep 13, 2012

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

@isao
Owner
isao commented Sep 13, 2012

also note:

semver.valid('0.4');//null
semver.valid('0.5')//null
@isao
Owner
isao commented Sep 13, 2012

in reference to yahoo/mojito#498

@isao
Owner
isao commented Oct 3, 2012

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.

@isao
Owner
isao commented Oct 3, 2012

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