diff options
author | isaacs <i@izs.me> | 2011-01-07 04:38:14 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-01-07 04:45:43 +0300 |
commit | 2ebbe8f8a42295d6bfeede87c4ea835dd5a6041d (patch) | |
tree | 94209ffe20aaf2411aef7d832e375e0ebd428413 | |
parent | 7826e2c091f53a107bf52fb70d2174294ce162c7 (diff) |
Detect edge case in use of npm's in-memory cache
-rw-r--r-- | lib/install.js | 4 | ||||
-rw-r--r-- | lib/utils/set.js | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/install.js b/lib/install.js index 747549c8d..0094a21e8 100644 --- a/lib/install.js +++ b/lib/install.js @@ -151,7 +151,7 @@ function install_ (pkg, reg, seen, mustHave, pkglist, bundles, cb) { }) } function installTargets (data) { - return Object.keys(data["dist-tags"]) + return Object.keys(data["dist-tags"] || {}) .concat(Object.keys(data.versions)) .map(JSON.stringify) .join(", ") || "(none)" @@ -159,7 +159,7 @@ function installTargets (data) { function getData (name, cb) { var data = npm.get(name) - if (data) return cb(null, data) + if (data && data["dist-tags"]) return cb(null, data) registry.get(name, function (er, data) { if (er) return cb(er) if (!data._id) data._id = name diff --git a/lib/utils/set.js b/lib/utils/set.js index 0d0b5cce5..4ab845915 100644 --- a/lib/utils/set.js +++ b/lib/utils/set.js @@ -13,9 +13,11 @@ function set (obj, key, val) { if (typeof val.versions[v] !== "object") return set(obj, key+"@"+v, val.versions[v]) }) + // Note that this doesn't put the dist-tags there, only updates the versions if (key === val.name+"@"+val.version) { processJson(val) var reg = get(obj, val.name) || {} + reg.name = reg._id = val.name set(obj, val.name, reg) reg.versions = get(reg, "versions") || {} if (!get(reg.versions, val.version)) set(reg.versions, val.version, val) |