From e79ccee1685393e4ec73746bac93835cbcf3a809 Mon Sep 17 00:00:00 2001
From: Forrest L Norvell As a command-line utility:$ semver -h
-Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | -d <dec>]
+Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | --preid <identifier> | -l | -rv]
Test if version(s) satisfy the supplied range(s), and sort them.
Multiple versions or ranges may be supplied, unless increment
-or decrement options are specified. In that case, only a single
-version may be used, and it is incremented by the specified level
+option is specified. In that case, only a single version may
+be used, and it is incremented by the specified level
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
@@ -91,6 +91,20 @@ alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the next set of prerelease versions.
The method .inc
takes an additional identifier
string argument that
+will append the value of the string as a prerelease identifier:
> semver.inc('1.2.3', 'pre', 'beta')
+'1.2.4-beta.0'
+
+command-line example:
+$ semver 1.2.3 -i prerelease --preid beta
+1.2.4-beta.0
+
+Which then can be used to increment further:
+$ semver 1.2.4-beta.0 -i prerelease
+1.2.4-beta.1
+
Advanced range syntax desugars to primitive comparators in deterministic ways.
@@ -145,7 +159,6 @@ equal tobeta.2
. So, 1.2.3-beta.4
would be allowed, b
1.2.4-beta.2
would not, because it is a prerelease of a
different [major, minor, patch]
tuple.
-Note: this is the same as the ~>
operator in rubygems.
^1.2.3
^0.2.5
^0.0.4
Allows changes that do not modify the left-most non-zero digit in the
[major, minor, patch]
tuple. In other words, this allows patch and
@@ -225,6 +238,9 @@ invalid comparison string is provided.
v2
is greater. Sorts in ascending order if passed to Array.sort()
.
rcompare(v1, v2)
: The reverse of compare. Sorts an array of versions
in descending order when passed to Array.sort()
.diff(v1, v2)
: Returns difference between two versions by the release type
+(major
, premajor
, minor
, preminor
, patch
, prepatch
, or prerelease
),
+or null if the versions are the same.satisfies(version, range)
function.