diff options
author | isaacs <i@izs.me> | 2011-03-28 22:53:15 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-03-30 09:04:59 +0400 |
commit | 4250a30198f469def627ad041e478789b56c61a4 (patch) | |
tree | 81e755bc1f119b0d9c07223a923a4b8c4baacd3e /lib | |
parent | 7adb2236479a839c5e85d9a5f836eeb19bbdfeef (diff) |
Move bin-tag stuff into a separate file
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cache.js | 13 | ||||
-rw-r--r-- | lib/utils/bin-tag.js | 16 |
2 files changed, 17 insertions, 12 deletions
diff --git a/lib/cache.js b/lib/cache.js index 4030b5bd0..5eda1917a 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -50,7 +50,7 @@ var mkdir = require("./utils/mkdir-p") , FMODE = tar.FMODE , DMODE = tar.DMODE , fileCompletion = require("./utils/completion/file-completion") - , os = require("os") + , binTag = require("./utils/bin-tag") cache.usage = "npm cache add <tarball file>" + "\nnpm cache add <folder>" @@ -276,17 +276,6 @@ function installTargetsError (requested, data) { .concat(Object.keys(data.versions)))) } -var binTagMemo -function binTag () { - if (binTagMemo || binTagMemo === null) return binTagMemo - var nv = semver.parse(npm.config.get("node-version")) - , platform = process.platform - , release = os.release() - if (!nv) return binTagMemo = null // weird? - nv = !(+nv[2] % 2) ? (nv[1] + "." + nv[2]) : nv[0] - return binTagMemo = nv + "-" + platform + "-" + release -} - function addNameVersion (name, ver, cb) { ver = semver.valid(ver) if (ver === null) return cb(new Error("Invalid version: "+ver)) diff --git a/lib/utils/bin-tag.js b/lib/utils/bin-tag.js new file mode 100644 index 000000000..2d0557144 --- /dev/null +++ b/lib/utils/bin-tag.js @@ -0,0 +1,16 @@ +module.exports = binTag + +var binTagMemo + , os = require("os") + , npm = require("../../npm") + , semver = require("semver") + +function binTag () { + if (binTagMemo || binTagMemo === null) return binTagMemo + var nv = semver.parse(npm.config.get("node-version")) + , platform = process.platform + , release = os.release() + if (!nv) return binTagMemo = null // weird? + nv = !(+nv[2] % 2) ? (nv[1] + "." + nv[2]) : nv[0] + return binTagMemo = nv + "-" + platform + "-" + release +} |