Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-02-12 03:16:18 +0300
committerisaacs <i@izs.me>2011-02-12 03:16:18 +0300
commitd876c4a5827366fdbd39787730abcde36142f7e6 (patch)
tree58d89c8629773b99f484d954c56ae573128b7760 /bin
parent5ac308894fb8d55db552748eca3108011edf251e (diff)
Closes GH-547 Split semver into a separate utility
Diffstat (limited to 'bin')
-rwxr-xr-xbin/npm.js2
-rw-r--r--bin/semver.js62
2 files changed, 1 insertions, 63 deletions
diff --git a/bin/npm.js b/bin/npm.js
index 65e1bf003..d026dfad7 100755
--- a/bin/npm.js
+++ b/bin/npm.js
@@ -30,7 +30,7 @@ if (conf.version) {
log("node@"+process.version, "using")
// make sure that this version of node works with this version of npm.
-var semver = require("../lib/utils/semver")
+var semver = require("semver")
, nodeVer = process.version
, reqVer = npm.nodeVersionRequired
if (reqVer && !semver.satisfies(nodeVer, reqVer)) {
diff --git a/bin/semver.js b/bin/semver.js
deleted file mode 100644
index 5261de134..000000000
--- a/bin/semver.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// Standalone semver comparison program.
-// Exits successfully and prints matching version(s) if
-// any supplied version is valid and passes all tests.
-
-var argv = process.argv.slice(2)
- , versions = []
- , range = []
- , gt = []
- , lt = []
- , eq = []
- , semver = require("../lib/utils/semver")
-
-main()
-
-function main () {
- if (!argv.length) return help()
- while (argv.length) {
- switch (argv.shift()) {
- case "-v": case "--version":
- versions.push(argv.shift())
- break
- case "-r" : case "--range":
- range.push(argv.shift())
- break
- default:
- return help()
- }
- }
- versions = versions.filter(semver.valid)
- for (var i = 0, l = range.length; i < l ; i ++) {
- versions = versions.filter(function (v) {
- return semver.satisfies(v, range[i])
- })
- if (!versions.length) return fail()
- }
- return success(versions)
-}
-
-function fail () { process.exit(1) }
-
-function success () {
- versions.sort(semver.compare).forEach(function (v,i,_) { console.log(v) })
-}
-
-function help () {
- console.log(["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 all versions satisfy all"
- ,"ranges and are valid, 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."
- ].join("\n"))
-}
-
-