Permalink
Browse files

Fix for http://github.com/mde/geddy/issues/issue/33 -- min Node versi…

…on parsing.
  • Loading branch information...
1 parent cc7d44e commit 36092e8757a42d92f1a6c81272cec0d69d921a1a mde committed Aug 21, 2010
Showing with 16 additions and 11 deletions.
  1. +16 −11 geddy-core/scripts/startserv.js
@@ -41,20 +41,25 @@ var die = function (str) {
process.exit();
}
-// check node dependency
-// we must iterate because node v0.1.100 fails:
-//
-// unfortunately "0.1.100" < "0.1.98" returns true
-//
-var processVersonArray = process.version.split(".");
-var minNodeVersonArray = MIN_NODE_VERSION.split(".");
-
-for (var i = 0; i < 3; i++) {
- if (parseInt(processVersonArray[i]) < parseInt(minNodeVersonArray[i])){
- die('Geddy requires ' + MIN_NODE_VERSION + ' of Node.js.');
+var checkMinVersion = function () {
+ var processVersonArray = process.version.replace(/^v/, '').split(".");
+ var minNodeVersonArray = MIN_NODE_VERSION.split(".");
+ for (var i = 0; i < 3; i++) {
+ // If the current level is actually a higher version than required,
+ // no need to check the next level down
+ if (parseInt(processVersonArray[i]) > parseInt(minNodeVersonArray[i])){
+ return;
+ }
+ // If the current level is lower than the required one, die
+ if (parseInt(processVersonArray[i]) < parseInt(minNodeVersonArray[i])){
+ die('Geddy requires ' + MIN_NODE_VERSION + ' of Node.js.');
+ }
+ // If the two are equal, need to go to the next level and check again ...
}
}
+checkMinVersion();
+
if (typeof opts.version != 'undefined') {
die(GEDDY_VERSION);
}

2 comments on commit 36092e8

tj replied Aug 21, 2010

whoop! will try it out again soonish

Contributor

mde replied Aug 21, 2010

Hey, man, thanks for catching this. :)

Please sign in to comment.