You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

221 lines
4.9 KiB

.\" Generated with Ronnjs 0.3.8
.\" http://github.com/kapouer/ronnjs/
.
.TH "NPM\-SEMVER" "1" "October 2012" "" ""
.
.SH "NAME"
\fBnpm-semver\fR \-\- The semantic versioner for npm
.
.SH "SYNOPSIS"
The npm semantic versioning utility\.
.
.SH "DESCRIPTION"
As a node module:
.
.IP "" 4
.
.nf
$ npm install semver
semver\.valid(\'1\.2\.3\') // true
semver\.valid(\'a\.b\.c\') // false
semver\.clean(\' =v1\.2\.3 \') // \'1\.2\.3\'
semver\.satisfies(\'1\.2\.3\', \'1\.x || >=2\.5\.0 || 5\.0\.0 \- 7\.2\.3\') // true
semver\.gt(\'1\.2\.3\', \'9\.8\.7\') // false
semver\.lt(\'1\.2\.3\', \'9\.8\.7\') // true
.
.fi
.
.IP "" 0
.
.P
As a command\-line utility:
.
.IP "" 4
.
.nf
$ npm install semver \-g
$ semver \-h
Usage: semver \-v <version> [\-r <range>]
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\.
.
.fi
.
.IP "" 0
.
.SH "Versions"
A version is the following things, in this order:
.
.IP "\(bu" 4
a number (Major)
.
.IP "\(bu" 4
a period
.
.IP "\(bu" 4
a number (minor)
.
.IP "\(bu" 4
a period
.
.IP "\(bu" 4
a number (patch)
.
.IP "\(bu" 4
OPTIONAL: a hyphen, followed by a number (build)
.
.IP "\(bu" 4
OPTIONAL: a collection of pretty much any non\-whitespace characters
(tag)
.
.IP "" 0
.
.P
A leading \fB"="\fR or \fB"v"\fR character is stripped off and ignored\.
.
.SH "Comparisons"
The ordering of versions is done using the following algorithm, given
two versions and asked to find the greater of the two:
.
.IP "\(bu" 4
If the majors are numerically different, then take the one
with a bigger major number\. \fB2\.3\.4 > 1\.3\.4\fR
.
.IP "\(bu" 4
If the minors are numerically different, then take the one
with the bigger minor number\. \fB2\.3\.4 > 2\.2\.4\fR
.
.IP "\(bu" 4
If the patches are numerically different, then take the one with the
bigger patch number\. \fB2\.3\.4 > 2\.3\.3\fR
.
.IP "\(bu" 4
If only one of them has a build number, then take the one with the
build number\. \fB2\.3\.4\-0 > 2\.3\.4\fR
.
.IP "\(bu" 4
If they both have build numbers, and the build numbers are numerically
different, then take the one with the bigger build number\. \fB2\.3\.4\-10 > 2\.3\.4\-9\fR
.
.IP "\(bu" 4
If only one of them has a tag, then take the one without the tag\. \fB2\.3\.4 > 2\.3\.4\-beta\fR
.
.IP "\(bu" 4
If they both have tags, then take the one with the lexicographically
larger tag\. \fB2\.3\.4\-beta > 2\.3\.4\-alpha\fR
.
.IP "\(bu" 4
At this point, they\'re equal\.
.
.IP "" 0
.
.SH "Ranges"
The following range styles are supported:
.
.IP "\(bu" 4
\fB>1\.2\.3\fR Greater than a specific version\.
.
.IP "\(bu" 4
\fB<1\.2\.3\fR Less than
.
.IP "\(bu" 4
\fB1\.2\.3 \- 2\.3\.4\fR := \fB>=1\.2\.3 <=2\.3\.4\fR
.
.IP "\(bu" 4
\fB~1\.2\.3\fR := \fB>=1\.2\.3 <1\.3\.0\fR
.
.IP "\(bu" 4
\fB~1\.2\fR := \fB>=1\.2\.0 <2\.0\.0\fR
.
.IP "\(bu" 4
\fB~1\fR := \fB>=1\.0\.0 <2\.0\.0\fR
.
.IP "\(bu" 4
\fB1\.2\.x\fR := \fB>=1\.2\.0 <1\.3\.0\fR
.
.IP "\(bu" 4
\fB1\.x\fR := \fB>=1\.0\.0 <2\.0\.0\fR
.
.IP "" 0
.
.P
Ranges can be joined with either a space (which implies "and") or a \fB||\fR (which implies "or")\.
.
.SH "Functions"
.
.IP "\(bu" 4
valid(v): Return the parsed version, or null if it\'s not valid\.
.
.IP "\(bu" 4
inc(v, release): Return the version incremented by the release type
(major, minor, patch, or build), or null if it\'s not valid\.
.
.IP "" 0
.
.SS "Comparison"
.
.IP "\(bu" 4
gt(v1, v2): \fBv1 > v2\fR
.
.IP "\(bu" 4
gte(v1, v2): \fBv1 >= v2\fR
.
.IP "\(bu" 4
lt(v1, v2): \fBv1 < v2\fR
.
.IP "\(bu" 4
lte(v1, v2): \fBv1 <= v2\fR
.
.IP "\(bu" 4
eq(v1, v2): \fBv1 == v2\fR This is true if they\'re logically equivalent,
even if they\'re not the exact same string\. You already know how to
compare strings\.
.
.IP "\(bu" 4
neq(v1, v2): \fBv1 != v2\fR The opposite of eq\.
.
.IP "\(bu" 4
cmp(v1, comparator, v2): Pass in a comparison string, and it\'ll call
the corresponding function above\. \fB"==="\fR and \fB"!=="\fR do simple
string comparison, but are included for completeness\. Throws if an
invalid comparison string is provided\.
.
.IP "\(bu" 4
compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or \-1 if
v2 is greater\. Sorts in ascending order if passed to Array\.sort()\.
.
.IP "\(bu" 4
rcompare(v1, v2): The reverse of compare\. Sorts an array of versions
in descending order when passed to Array\.sort()\.
.
.IP "" 0
.
.SS "Ranges"
.
.IP "\(bu" 4
validRange(range): Return the valid range or null if it\'s not valid
.
.IP "\(bu" 4
satisfies(version, range): Return true if the version satisfies the
range\.
.
.IP "\(bu" 4
maxSatisfying(versions, range): Return the highest version in the list
that satisfies the range, or null if none of them do\.
.
.IP "" 0
.
.SH "SEE ALSO"
.
.IP "\(bu" 4
npm help json
.
.IP "" 0