Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/node-semver
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.6.0
Choose a base ref
...
head repository: npm/node-semver
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.7.0
Choose a head ref

Commits on Oct 11, 2018

  1. Copy the full SHA
    e5e3620 View commit details

Commits on Oct 12, 2018

  1. test:💥 something amazing is in the works 💥

    Benjamin authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    ad1c3d2 View commit details
  2. chore: turn of CLI invokation for now

    Benjamin authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    9480467 View commit details
  3. 2
    Copy the full SHA
    cb71dbb View commit details
  4. Copy the full SHA
    b925b4f View commit details
  5. Apply 'standard' to semver.js

    pjohnmeyer authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    7c2638f View commit details
  6. Apply 'standard' to test/big-numbers.js

    pjohnmeyer authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    8bcd207 View commit details
  7. Apply 'standard' to test/cli.js

    pjohnmeyer authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    824e08a View commit details
  8. Apply 'standard' to test/index.js

    pjohnmeyer authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    42e765b View commit details
  9. Copy the full SHA
    b30f2ce View commit details
  10. Copy the full SHA
    a34ca82 View commit details
  11. Copy the full SHA
    a4ff4ff View commit details
  12. Move 'standard' from scripts.test to .posttest

    Close #258
    pjohnmeyer authored and isaacs committed Oct 12, 2018
    Copy the full SHA
    347d4a0 View commit details
  13. Add changelog, fix #220

    isaacs committed Oct 12, 2018
    1
    Copy the full SHA
    a1b6cb8 View commit details

Commits on Oct 15, 2018

  1. Use https when possible. (#246)

    XhmikosR authored and isaacs committed Oct 15, 2018
    Copy the full SHA
    c529221 View commit details

Commits on Oct 16, 2018

  1. Document includePrerelease flag more

    Include it in the section on Prerelease Tags in the range description
    section.
    isaacs committed Oct 16, 2018
    Copy the full SHA
    a462bec View commit details

Commits on Oct 18, 2018

  1. remove node 4

    Tap doesn't work well on node 4 windows, and it's past LTS.
    isaacs committed Oct 18, 2018
    1
    Copy the full SHA
    6086e5a View commit details

Commits on Jan 18, 2019

  1. Copy the full SHA
    b99ae3b View commit details

Commits on Mar 26, 2019

  1. next-gen tap for testing

    isaacs committed Mar 26, 2019
    Copy the full SHA
    1af213f View commit details
  2. drop windows testing

    This isn't really a cross-platform lib, so there isn't much value in it,
    and it's pretty flaky right now.
    isaacs committed Mar 26, 2019
    Copy the full SHA
    4d8306b View commit details
  3. Copy the full SHA
    da8a771 View commit details
  4. 5.7 changelog

    isaacs committed Mar 26, 2019
    Copy the full SHA
    38d42ca View commit details
  5. document parse method

    isaacs committed Mar 26, 2019
    Copy the full SHA
    9cb68f1 View commit details
  6. Copy the full SHA
    bed01e2 View commit details
  7. auto-publishing scripts

    isaacs committed Mar 26, 2019
    Copy the full SHA
    604e73d View commit details
  8. 5.7.0

    isaacs committed Mar 26, 2019
    Copy the full SHA
    8055dda View commit details
Showing with 3,511 additions and 3,468 deletions.
  1. +10 −5 .travis.yml
  2. +39 −0 CHANGELOG.md
  3. +14 −2 README.md
  4. +84 −77 bin/semver
  5. +1,817 −2,101 package-lock.json
  6. +10 −4 package.json
  7. +906 −775 semver.js
  8. +2 −2 test/big-numbers.js
  9. +28 −28 test/clean.js
  10. +29 −28 test/cli.js
  11. +18 −18 test/coerce.js
  12. +24 −24 test/gtr.js
  13. +382 −332 test/index.js
  14. +24 −24 test/ltr.js
  15. +33 −33 test/major-minor-patch.js
  16. +76 −0 test/min-version.js
  17. +15 −15 test/prerelease.js
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
language: node_js
sudo: false

node_js:
- 11
- 10
- 8
- 6
- 4
notifications:
email: false

os:
- linux

cache:
directories:
- $HOME/.npm

notifications:
email: false
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# changes log

## 5.7

* Add `minVersion` method

## 5.6

* Move boolean `loose` param to an options object, with
backwards-compatibility protection.
* Add ability to opt out of special prerelease version handling with
the `includePrerelease` option flag.

## 5.5

* Add version coercion capabilities

## 5.4

* Add intersection checking

## 5.3

* Add `minSatisfying` method

## 5.2

* Add `prerelease(v)` that returns prerelease components

## 5.1

* Add Backus-Naur for ranges
* Remove excessively cute inspection methods

## 5.0

* Remove AMD/Browserified build artifacts
* Fix ltr and gtr when using the `*` range
* Fix for range `*` with a prerelease identifier
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ 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
semver.minVersion('>=1.0.0') // '1.0.0'
semver.valid(semver.coerce('v2')) // '2.0.0'
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
```
@@ -29,7 +30,7 @@ As a command-line utility:
```
$ semver -h

A JavaScript implementation of the http://semver.org/ specification
A JavaScript implementation of the https://semver.org/ specification
Copyright Isaac Z. Schlueter

Usage: semver [options] <version> [<version> [...]]
@@ -71,7 +72,7 @@ multiple versions to the utility will just sort them.
## Versions
A "version" is described by the `v2.0.0` specification found at
<http://semver.org/>.
<https://semver.org/>.
A leading `"="` or `"v"` character is stripped off and ignored.
@@ -137,6 +138,13 @@ 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.
Note that this behavior can be suppressed (treating all prerelease
versions as if they were normal versions, for the purpose of range
matching) by setting the `includePrerelease` flag on the options
object to any
[functions](https://github.com/npm/node-semver#functions) that do
range matching.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
@@ -325,6 +333,8 @@ strings that they parse.
* `patch(v)`: Return the patch version number.
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
or comparators intersect.
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
a `SemVer` object or `null`.

### Comparison

@@ -361,6 +371,8 @@ strings that they parse.
that satisfies the range, or `null` if none of them do.
* `minSatisfying(versions, range)`: Return the lowest version in the list
that satisfies the range, or `null` if none of them do.
* `minVersion(range)`: Return the lowest version that can possibly match
the given range.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
161 changes: 84 additions & 77 deletions bin/semver
Original file line number Diff line number Diff line change
@@ -4,66 +4,74 @@
// any supplied version is valid and passes all tests.

var argv = process.argv.slice(2)
, versions = []
, range = []
, gt = []
, lt = []
, eq = []
, inc = null
, version = require("../package.json").version
, loose = false
, includePrerelease = false
, coerce = false
, identifier = undefined
, semver = require("../semver")
, reverse = false
, options = {}

var versions = []

var range = []

var inc = null

var version = require('../package.json').version

var loose = false

var includePrerelease = false

var coerce = false

var identifier

var semver = require('../semver')

var reverse = false

var options = {}

main()

function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var i = a.indexOf('=')
if (i !== -1) {
a = a.slice(0, i)
argv.unshift(a.slice(i + 1))
var indexOfEqualSign = a.indexOf('=')
if (indexOfEqualSign !== -1) {
a = a.slice(0, indexOfEqualSign)
argv.unshift(a.slice(indexOfEqualSign + 1))
}
switch (a) {
case "-rv": case "-rev": case "--rev": case "--reverse":
case '-rv': case '-rev': case '--rev': case '--reverse':
reverse = true
break
case "-l": case "--loose":
case '-l': case '--loose':
loose = true
break
case "-p": case "--include-prerelease":
case '-p': case '--include-prerelease':
includePrerelease = true
break
case "-v": case "--version":
case '-v': case '--version':
versions.push(argv.shift())
break
case "-i": case "--inc": case "--increment":
case '-i': case '--inc': case '--increment':
switch (argv[0]) {
case "major": case "minor": case "patch": case "prerelease":
case "premajor": case "preminor": case "prepatch":
case 'major': case 'minor': case 'patch': case 'prerelease':
case 'premajor': case 'preminor': case 'prepatch':
inc = argv.shift()
break
default:
inc = "patch"
inc = 'patch'
break
}
break
case "--preid":
case '--preid':
identifier = argv.shift()
break
case "-r": case "--range":
case '-r': case '--range':
range.push(argv.shift())
break
case "-c": case "--coerce":
case '-c': case '--coerce':
coerce = true
break
case "-h": case "--help": case "-?":
case '-h': case '--help': case '-?':
return help()
default:
versions.push(a)
@@ -74,15 +82,14 @@ function main () {
var options = { loose: loose, includePrerelease: includePrerelease }

versions = versions.map(function (v) {
return coerce ? (semver.coerce(v) || {version: v}).version : v
return coerce ? (semver.coerce(v) || { version: v }).version : v
}).filter(function (v) {
return semver.valid(v)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length))
return failInc()
if (inc && (versions.length !== 1 || range.length)) { return failInc() }

for (var i = 0, l = range.length; i < l ; i ++) {
for (var i = 0, l = range.length; i < l; i++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], options)
})
@@ -92,62 +99,62 @@ function main () {
}

function failInc () {
console.error("--inc can only be used on a single version with no range")
console.error('--inc can only be used on a single version with no range')
fail()
}

function fail () { process.exit(1) }

function success () {
var compare = reverse ? "rcompare" : "compare"
var compare = reverse ? 'rcompare' : 'compare'
versions.sort(function (a, b) {
return semver[compare](a, b, options)
}).map(function (v) {
return semver.clean(v, options)
}).map(function (v) {
return inc ? semver.inc(v, inc, options, identifier) : v
}).forEach(function (v,i,_) { console.log(v) })
}).forEach(function (v, i, _) { console.log(v) })
}

function help () {
console.log(["SemVer " + version
,""
,"A JavaScript implementation of the http://semver.org/ specification"
,"Copyright Isaac Z. Schlueter"
,""
,"Usage: semver [options] <version> [<version> [...]]"
,"Prints valid versions sorted by SemVer precedence"
,""
,"Options:"
,"-r --range <range>"
," Print versions that match the specified range."
,""
,"-i --increment [<level>]"
," Increment a version by the specified level. Level can"
," be one of: major, minor, patch, premajor, preminor,"
," prepatch, or prerelease. Default level is 'patch'."
," Only one version may be specified."
,""
,"--preid <identifier>"
," Identifier to be used to prefix premajor, preminor,"
," prepatch or prerelease version increments."
,""
,"-l --loose"
," Interpret versions and ranges loosely"
,""
,"-p --include-prerelease"
," Always include prerelease versions in range matching"
,""
,"-c --coerce"
," Coerce a string into SemVer if possible"
," (does not imply --loose)"
,""
,"Program exits successfully if any valid version satisfies"
,"all supplied ranges, and prints all satisfying versions."
,""
,"If no satisfying versions are found, then exits failure."
,""
,"Versions are printed in ascending order, so supplying"
,"multiple versions to the utility will just sort them."
].join("\n"))
console.log(['SemVer ' + version,
'',
'A JavaScript implementation of the https://semver.org/ specification',
'Copyright Isaac Z. Schlueter',
'',
'Usage: semver [options] <version> [<version> [...]]',
'Prints valid versions sorted by SemVer precedence',
'',
'Options:',
'-r --range <range>',
' Print versions that match the specified range.',
'',
'-i --increment [<level>]',
' Increment a version by the specified level. Level can',
' be one of: major, minor, patch, premajor, preminor,',
" prepatch, or prerelease. Default level is 'patch'.",
' Only one version may be specified.',
'',
'--preid <identifier>',
' Identifier to be used to prefix premajor, preminor,',
' prepatch or prerelease version increments.',
'',
'-l --loose',
' Interpret versions and ranges loosely',
'',
'-p --include-prerelease',
' Always include prerelease versions in range matching',
'',
'-c --coerce',
' Coerce a string into SemVer if possible',
' (does not imply --loose)',
'',
'Program exits successfully if any valid version satisfies',
'all supplied ranges, and prints all satisfying versions.',
'',
'If no satisfying versions are found, then exits failure.',
'',
'Versions are printed in ascending order, so supplying',
'multiple versions to the utility will just sort them.'
].join('\n'))
}
Loading