The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / npm / man / man1 / semver.1 @ 5aef65a9

History | View | Annotate | Download (4.94 KB)

1
.\" Generated with Ronnjs 0.3.8
2
.\" http://github.com/kapouer/ronnjs/
3
.
4
.TH "NPM\-SEMVER" "1" "February 2013" "" ""
5
.
6
.SH "NAME"
7
\fBnpm-semver\fR \-\- The semantic versioner for npm
8
.
9
.SH "SYNOPSIS"
10
The npm semantic versioning utility\.
11
.
12
.SH "DESCRIPTION"
13
As a node module:
14
.
15
.IP "" 4
16
.
17
.nf
18
$ npm install semver
19
semver\.valid(\'1\.2\.3\') // \'1\.2\.3\'
20
semver\.valid(\'a\.b\.c\') // null
21
semver\.clean(\'  =v1\.2\.3   \') // \'1\.2\.3\'
22
semver\.satisfies(\'1\.2\.3\', \'1\.x || >=2\.5\.0 || 5\.0\.0 \- 7\.2\.3\') // true
23
semver\.gt(\'1\.2\.3\', \'9\.8\.7\') // false
24
semver\.lt(\'1\.2\.3\', \'9\.8\.7\') // true
25
.
26
.fi
27
.
28
.IP "" 0
29
.
30
.P
31
As a command\-line utility:
32
.
33
.IP "" 4
34
.
35
.nf
36
$ npm install semver \-g
37
$ semver \-h
38
Usage: semver \-v <version> [\-r <range>]
39
Test if version(s) satisfy the supplied range(s),
40
and sort them\.
41
Multiple versions or ranges may be supplied\.
42
Program exits successfully if any valid version satisfies
43
all supplied ranges, and prints all satisfying versions\.
44
If no versions are valid, or ranges are not satisfied,
45
then exits failure\.
46
Versions are printed in ascending order, so supplying
47
multiple versions to the utility will just sort them\.
48
.
49
.fi
50
.
51
.IP "" 0
52
.
53
.SH "Versions"
54
A version is the following things, in this order:
55
.
56
.IP "\(bu" 4
57
a number (Major)
58
.
59
.IP "\(bu" 4
60
a period
61
.
62
.IP "\(bu" 4
63
a number (minor)
64
.
65
.IP "\(bu" 4
66
a period
67
.
68
.IP "\(bu" 4
69
a number (patch)
70
.
71
.IP "\(bu" 4
72
OPTIONAL: a hyphen, followed by a number (build)
73
.
74
.IP "\(bu" 4
75
OPTIONAL: a collection of pretty much any non\-whitespace characters
76
(tag)
77
.
78
.IP "" 0
79
.
80
.P
81
A leading \fB"="\fR or \fB"v"\fR character is stripped off and ignored\.
82
.
83
.SH "Comparisons"
84
The ordering of versions is done using the following algorithm, given
85
two versions and asked to find the greater of the two:
86
.
87
.IP "\(bu" 4
88
If the majors are numerically different, then take the one
89
with a bigger major number\. \fB2\.3\.4 > 1\.3\.4\fR
90
.
91
.IP "\(bu" 4
92
If the minors are numerically different, then take the one
93
with the bigger minor number\. \fB2\.3\.4 > 2\.2\.4\fR
94
.
95
.IP "\(bu" 4
96
If the patches are numerically different, then take the one with the
97
bigger patch number\. \fB2\.3\.4 > 2\.3\.3\fR
98
.
99
.IP "\(bu" 4
100
If only one of them has a build number, then take the one with the
101
build number\.  \fB2\.3\.4\-0 > 2\.3\.4\fR
102
.
103
.IP "\(bu" 4
104
If they both have build numbers, and the build numbers are numerically
105
different, then take the one with the bigger build number\. \fB2\.3\.4\-10 > 2\.3\.4\-9\fR
106
.
107
.IP "\(bu" 4
108
If only one of them has a tag, then take the one without the tag\. \fB2\.3\.4 > 2\.3\.4\-beta\fR
109
.
110
.IP "\(bu" 4
111
If they both have tags, then take the one with the lexicographically
112
larger tag\.  \fB2\.3\.4\-beta > 2\.3\.4\-alpha\fR
113
.
114
.IP "\(bu" 4
115
At this point, they\'re equal\.
116
.
117
.IP "" 0
118
.
119
.SH "Ranges"
120
The following range styles are supported:
121
.
122
.IP "\(bu" 4
123
\fB>1\.2\.3\fR Greater than a specific version\.
124
.
125
.IP "\(bu" 4
126
\fB<1\.2\.3\fR Less than
127
.
128
.IP "\(bu" 4
129
\fB1\.2\.3 \- 2\.3\.4\fR := \fB>=1\.2\.3 <=2\.3\.4\fR
130
.
131
.IP "\(bu" 4
132
\fB~1\.2\.3\fR := \fB>=1\.2\.3 <1\.3\.0\fR
133
.
134
.IP "\(bu" 4
135
\fB~1\.2\fR := \fB>=1\.2\.0 <1\.3\.0\fR
136
.
137
.IP "\(bu" 4
138
\fB~1\fR := \fB>=1\.0\.0 <2\.0\.0\fR
139
.
140
.IP "\(bu" 4
141
\fB1\.2\.x\fR := \fB>=1\.2\.0 <1\.3\.0\fR
142
.
143
.IP "\(bu" 4
144
\fB1\.x\fR := \fB>=1\.0\.0 <2\.0\.0\fR
145
.
146
.IP "" 0
147
.
148
.P
149
Ranges can be joined with either a space (which implies "and") or a \fB||\fR (which implies "or")\.
150
.
151
.SH "Functions"
152
.
153
.IP "\(bu" 4
154
valid(v): Return the parsed version, or null if it\'s not valid\.
155
.
156
.IP "\(bu" 4
157
inc(v, release): Return the version incremented by the release type
158
(major, minor, patch, or build), or null if it\'s not valid\.
159
.
160
.IP "" 0
161
.
162
.SS "Comparison"
163
.
164
.IP "\(bu" 4
165
gt(v1, v2): \fBv1 > v2\fR
166
.
167
.IP "\(bu" 4
168
gte(v1, v2): \fBv1 >= v2\fR
169
.
170
.IP "\(bu" 4
171
lt(v1, v2): \fBv1 < v2\fR
172
.
173
.IP "\(bu" 4
174
lte(v1, v2): \fBv1 <= v2\fR
175
.
176
.IP "\(bu" 4
177
eq(v1, v2): \fBv1 == v2\fR This is true if they\'re logically equivalent,
178
even if they\'re not the exact same string\.  You already know how to
179
compare strings\.
180
.
181
.IP "\(bu" 4
182
neq(v1, v2): \fBv1 != v2\fR The opposite of eq\.
183
.
184
.IP "\(bu" 4
185
cmp(v1, comparator, v2): Pass in a comparison string, and it\'ll call
186
the corresponding function above\.  \fB"==="\fR and \fB"!=="\fR do simple
187
string comparison, but are included for completeness\.  Throws if an
188
invalid comparison string is provided\.
189
.
190
.IP "\(bu" 4
191
compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or \-1 if
192
v2 is greater\.  Sorts in ascending order if passed to Array\.sort()\.
193
.
194
.IP "\(bu" 4
195
rcompare(v1, v2): The reverse of compare\.  Sorts an array of versions
196
in descending order when passed to Array\.sort()\.
197
.
198
.IP "" 0
199
.
200
.SS "Ranges"
201
.
202
.IP "\(bu" 4
203
validRange(range): Return the valid range or null if it\'s not valid
204
.
205
.IP "\(bu" 4
206
satisfies(version, range): Return true if the version satisfies the
207
range\.
208
.
209
.IP "\(bu" 4
210
maxSatisfying(versions, range): Return the highest version in the list
211
that satisfies the range, or null if none of them do\.
212
.
213
.IP "" 0
214
.
215
.SH "SEE ALSO"
216
.
217
.IP "\(bu" 4
218
npm help json
219
.
220
.IP "" 0
221