Permalink
Browse files

using issac's semver to compare module version numbers

  • Loading branch information...
1 parent 830c763 commit 01df5a95a54f486caa460ecc3574099696480228 @dylang committed Aug 4, 2011
Showing with 5 additions and 15 deletions.
  1. +3 −13 lib/npm.js
  2. +2 −1 package.json
  3. +0 −1 readme.md
View
@@ -1,21 +1,11 @@
var Request = require('request');
var Step = require('step');
var Github = require('./github');
+var Semver = require('semver');
function sortVersions (a, b) {
- a = a.split('.');
- b = b.split('.');
- a = [parseInt(a[0], 10), parseInt(a[1], 10), parseInt(a[2], 10)];
- b = [parseInt(b[0], 10), parseInt(b[1], 10), parseInt(b[2], 10)];
-
- if (a[0] > b[0]) return -1;
- if (a[0] < b[0]) return 1;
-
- if (a[1] > b[1]) return -1;
- if (a[1] < b[1]) return 1;
-
- if (a[2] > b[2]) return -1;
- if (a[2] < b[2]) return 1;
+ if (Semver.gt(a, b)) { return -1; }
+ if (Semver.lt(a, b)) { return 1; }
return 0;
}
View
@@ -28,7 +28,8 @@
"step": "*",
"request": "*",
"wordwrap": "*",
- "cli": "*"
+ "cli": "*",
+ "semver": "*"
},
"devDependencies": {
"logging": "*"
View
@@ -125,7 +125,6 @@ Future
* Use Git tags to detect versions
* Add examples
* Add header and/or footer to the markdown output
- * use node-semver to compare versions
* If the package.json does not have a propper repoistory link then show the author's name and email and suggest contacting the author.
Install

0 comments on commit 01df5a9

Please sign in to comment.