diff options
author | isaacs <i@izs.me> | 2010-07-03 11:10:51 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-07-03 11:10:51 +0400 |
commit | 77e2564022164baf01a32b7988d1ef7f53a9dfb9 (patch) | |
tree | d228dc5bffd5a5d48bc73666780851a4ca342086 | |
parent | f547e60b6cbd1a968b71714261210c384f846f43 (diff) |
Filter dependencies based on the running version of node. Fix #6
-rw-r--r-- | lib/install.js | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/install.js b/lib/install.js index 355fa4307..0f2e0ef6d 100644 --- a/lib/install.js +++ b/lib/install.js @@ -72,6 +72,8 @@ function registryInstall (pkglist, cb) { // that it's sitting in the cache function Continue (er, data) { if (er) return log.er(cb, "Error installing "+pkg)(er) + if (!data._nodeSupported) return cb(new Error( + data.name+"@"+data.version+" not compatible with node@"+process.version)) seen[data.name+"@"+data.version] = true var p = path.join(data.name, data.version) , ir = installReg @@ -172,7 +174,8 @@ function registryInstall (pkglist, cb) { // favor defTag version. var data = npm.get(name) , stable = data["dist-tags"] && data["dist-tags"][defTag] - if (stable && semver.satisfies(stable, range)) { + filterNodeVersion(data) + if (stable && semver.satisfies(stable, range) && data.versions[stable]) { log(data.versions[stable], name+"@"+defTag) stable = name + "@" + stable if (!seen[stable]) pkglist.push(stable) @@ -188,6 +191,15 @@ function registryInstall (pkglist, cb) { })(pkglist.shift()) } +function filterNodeVersion (data) { + for (var v in data.versions) { + log(data.versions[v]._nodeSupported, "nodeSupported by "+data.name+"@"+v) + if (!data.versions[v]._nodeSupported) { + delete data.versions[v] + } + } +} + function buildAll (list, cb) { if (list.length === 0) { return log("Nothing to install", "install", cb) |