diff options
author | isaacs <i@izs.me> | 2011-04-08 20:38:55 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-04-08 20:38:55 +0400 |
commit | 970d3538da66765de095269ed33bfe0229f4029b (patch) | |
tree | 1480845857ac00104a844da254f8c2634c743641 | |
parent | 24bc0851fafbdeb638db3c023954497e192ec665 (diff) |
Closes GH-787 Don't bypass cache for local installs.
Also, tone down some logging that was rather excessive.
-rw-r--r-- | lib/build.js | 4 | ||||
-rw-r--r-- | lib/cache.js | 9 | ||||
-rw-r--r-- | lib/install.js | 13 | ||||
-rw-r--r-- | lib/unbuild.js | 3 |
4 files changed, 17 insertions, 12 deletions
diff --git a/lib/build.js b/lib/build.js index 846896dd4..5d971aaca 100644 --- a/lib/build.js +++ b/lib/build.js @@ -74,10 +74,10 @@ function rebuildBundles (pkg, folder, parent, gtop, cb) { , bundles = pkg.bundleDependencies || pkg.bundledDependencies || [] fs.readdir(path.resolve(folder, "node_modules"), function (er, files) { - log.verbose([er, files], "rebuildBundles") // error means no bundles if (er) return cb() + log.verbose(files, "rebuildBundles") asyncMap(files.filter(function (file) { return file.charAt(0) !== "." && file.indexOf("@") === -1 @@ -99,7 +99,7 @@ function linkBins (pkg, folder, parent, gtop, cb) { if (!pkg.bin) return cb() var binRoot = gtop ? path.resolve(npm.config.get("prefix"), "bin") : path.resolve(parent, ".bin") - log([pkg.bin, binRoot], "bins linking") + log.verbose([pkg.bin, binRoot], "bins linking") asyncMap(Object.keys(pkg.bin), function (b, cb) { linkIfExists(path.resolve(folder, pkg.bin[b]) ,path.resolve(binRoot, b) diff --git a/lib/cache.js b/lib/cache.js index 0a1f98481..de6a00be7 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -95,7 +95,8 @@ function cache (args, cb) { // just do a readJson and return. // if they're not, then fetch them from the registry. var cacheSeen = {} -function read (name, ver, cb) { +function read (name, ver, forceBypass, cb) { + if (typeof cb !== "function") cb = forceBypass, forceBypass = true var jsonFile = path.join(npm.cache, name, ver, "package.json") function c (er, data) { if (!er) cacheSeen[data._id] = data @@ -103,7 +104,9 @@ function read (name, ver, cb) { return cb(er, data) } - if (npm.config.get("force") || process.platform === "cygwin") { + if (forceBypass + && (npm.config.get("force") + || process.platform === "cygwin")) { log.verbose(true, "force found, skipping cache") return addNamed(name, ver, c) } @@ -463,7 +466,7 @@ function unpack (pkg, ver, unpackTarget, dMode, fMode, uid, gid, cb) { if (typeof cb !== "function") cb = fMode, fMode = null if (typeof cb !== "function") cb = dMode, dMode = null - read(pkg, ver, function (er, data) { + read(pkg, ver, false, function (er, data) { if (er) { log.error("Could not read data for "+pkg+"@"+ver) return cb(er) diff --git a/lib/install.js b/lib/install.js index 083aceb95..2dfa476b4 100644 --- a/lib/install.js +++ b/lib/install.js @@ -149,7 +149,7 @@ function install (args, cb) { where = args args = [cb] cb = arguments[2] - log([where, args], "install(where, what)") + log.info([where, args], "install(where, what)") } if (!npm.config.get("global")) { @@ -223,7 +223,7 @@ function installManyTop (what, where, previously, explicit, cb) { } function installMany (what, where, previously, explicit, cb) { - log.info(what, "into "+where) + log.verbose(what, "into "+where) // what is a list of things. // resolve each one. asyncMap(what, targetResolver(where, previously, explicit) @@ -236,8 +236,9 @@ function installMany (what, where, previously, explicit, cb) { newPrev[t.name] = t.version }) log.silly(targets, "resolved") - log.info(targets.map(function (t) { return t && t._id}) - , "(resolved) into "+where) + targets.filter(function (t) { return t }).forEach(function (t) { + log.info(t._id, "into "+where) + }) asyncMap(targets, function (target, cb) { log(target._id, "installOne") installOne(target, where, newPrev, cb) @@ -262,7 +263,7 @@ function targetResolver (where, previously, explicit) { // now we know what's been installed here manually, // or tampered with in some way that npm doesn't want to overwrite. if (alreadyInstalledManually.indexOf(what.split("@").shift()) !== -1) { - log("skipping "+what, "already installed manually in "+where) + log.verbose("skipping "+what, "already installed in "+where) return cb(null, []) } cache.add(what, function (er, data) { @@ -286,7 +287,7 @@ function installOne (target, where, previously, cb) { , [checkGit, targetFolder] , [write, target, targetFolder, previously] , function (er) { - log.info(target._id, "installOne cb") + log.verbose(target._id, "installOne cb") if (er) return cb(er) if (!npm.config.get("global")) { // print out the folder relative to where we are right now. diff --git a/lib/unbuild.js b/lib/unbuild.js index 1babea4b4..0637b640d 100644 --- a/lib/unbuild.js +++ b/lib/unbuild.js @@ -17,6 +17,7 @@ function unbuild (args, cb) { asyncMap(args, unbuild_, cb) } function unbuild_ (folder, cb) { folder = path.resolve(folder) + log.info(folder, "unbuild") readJson(path.resolve(folder, "package.json"), function (er, pkg) { // if no json, then just trash it, but no scripts or whatever. if (er) return rm(folder, cb) @@ -38,7 +39,7 @@ function rmStuff (pkg, folder, cb) { , gnm = path.resolve(npm.config.get("prefix"), "node_modules") , top = gnm === parent - log([top, gnm, parent], "unbuild "+pkg._id) + log.verbose([top, gnm, parent], "unbuild "+pkg._id) asyncMap([rmBins, rmMans], function (fn, cb) { fn(pkg, folder, parent, top, cb) }, cb) |