diff options
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/npm.js | 1 | ||||
-rw-r--r-- | deps/npm/lib/outdated.js | 18 | ||||
-rw-r--r-- | deps/npm/lib/prune.js | 16 |
3 files changed, 29 insertions, 6 deletions
diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index 8b8ee95b0..0d1e32f0f 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -106,6 +106,7 @@ var commandCache = {} , "tst": "test" , "find-dupes": "dedupe" , "ddp": "dedupe" + , "v": "view" } , aliasNames = Object.keys(aliases) diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js index b21e10d06..d9ef3ca0b 100644 --- a/deps/npm/lib/outdated.js +++ b/deps/npm/lib/outdated.js @@ -24,6 +24,7 @@ var path = require("path") , cache = require("./cache.js") , asyncMap = require("slide").asyncMap , npm = require("./npm.js") + , url = require("url") function outdated (args, silent, cb) { if (typeof cb !== "function") cb = silent, silent = false @@ -143,7 +144,7 @@ function shouldUpdate (args, dir, dep, has, req, cb) { } function doIt (shouldHave) { - cb(null, [[ dir, dep, curr.version, shouldHave, req ]]) + cb(null, [[ dir, dep, curr && curr.version, shouldHave, req ]]) } if (args.length && args.indexOf(dep) === -1) { @@ -153,9 +154,18 @@ function shouldUpdate (args, dir, dep, has, req, cb) { // so, we can conceivably update this. find out if we need to. cache.add(dep, req, function (er, d) { // if this fails, then it means we can't update this thing. - // it's probably a thing that isn't published. otherwise - // check that the origin hasn't changed (#1727) and that + // it's probably a thing that isn't published. + if (er) return skip() + + // check that the url origin hasn't changed (#1727) and that // there is no newer version available - return (er || (d._from === curr.from && d.version === has[dep])) ? skip() : doIt(d.version) + var dFromUrl = d._from && url.parse(d._from).protocol + var cFromUrl = curr && curr.from && url.parse(curr.from).protocol + + if (!curr || dFromUrl && cFromUrl && d._from !== curr.from + || d.version !== curr.version) + doIt(d.version) + else + skip() }) } diff --git a/deps/npm/lib/prune.js b/deps/npm/lib/prune.js index 2afb2b998..dbe8790b9 100644 --- a/deps/npm/lib/prune.js +++ b/deps/npm/lib/prune.js @@ -6,13 +6,25 @@ prune.usage = "npm prune" var readInstalled = require("read-installed") , npm = require("./npm.js") + , path = require("path") + , readJson = require("read-package-json") + , log = require("npmlog") prune.completion = require("./utils/completion/installed-deep.js") function prune (args, cb) { - readInstalled(npm.prefix, npm.config.get("depth"), function (er, data) { + var jsonFile = path.resolve(npm.dir, "..", "package.json" ) + readJson(jsonFile, log.warn, function (er, packageData) { if (er) return cb(er) - prune_(args, data, cb) + readInstalled(npm.prefix, npm.config.get("depth"), function (er, data) { + if (er) return cb(er) + if (npm.config.get("production")) { + Object.keys(packageData.devDependencies || {}).forEach(function (k) { + if (data.dependencies[k]) data.dependencies[k].extraneous = true + }) + } + prune_(args, data, cb) + }) }) } |