Skip to content

@isao /rangecheck.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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

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

also note:

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

in reference to yahoo/mojito#498

@isao
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.

@isao
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.