From d876c4a5827366fdbd39787730abcde36142f7e6 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 11 Feb 2011 16:16:18 -0800 Subject: Closes GH-547 Split semver into a separate utility --- bin/npm.js | 2 +- bin/semver.js | 62 ----------------------------------------------------------- 2 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 bin/semver.js (limited to 'bin') 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 [-r ]" - ,"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")) -} - - -- cgit v1.2.3