diff options
author | isaacs <i@izs.me> | 2010-05-03 08:35:23 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2010-05-03 08:35:23 +0400 |
commit | 79d79cfc1bde77b3215c2d9769ea9db28d023de0 (patch) | |
tree | f881f9371aaa2b58eebe08235ed2081c95c5488d /lib | |
parent | d49a887411fceafa940c163ae83269e035ad6dc4 (diff) |
Change the way that the version stuff is set in the local registry, and install the stable version of npm by default
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils/set.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/utils/set.js b/lib/utils/set.js index 532d54c0f..6baa3e558 100644 --- a/lib/utils/set.js +++ b/lib/utils/set.js @@ -1,15 +1,14 @@ -module.exports = set; -var get = require("./get"); +module.exports = set +var get = require("./get") function set (obj, key, val) { - for (var i in obj) if (i.toLowerCase() === key.toLowerCase()) return obj[i] = val; - obj[key] = val; + for (var i in obj) if (i.toLowerCase() === key.toLowerCase()) return obj[i] = val + obj[key] = val if (val && val.version && key.indexOf("-"+val.version) !== -1) { - key = key.replace("-"+val.version, ""); - var reg = get(obj, key) || {}; - set(reg, val.version, val); - set(obj, key, reg); - reg._versions = get(reg, "_versions") || []; - reg._versions.push(val.version); + key = key.replace("-"+val.version, "") + var reg = get(obj, key) || {} + set(obj, key, reg) + reg.versions = get(reg, "versions") || {} + if (!get(reg.versions, val.version)) set(reg.versions, val.version, val) } } |