diff options
author | isaacs <i@izs.me> | 2013-05-30 10:19:45 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-05-30 10:19:45 -0700 |
commit | c86afa5d2eeeb841f879fb4903484dabb769862a (patch) | |
tree | 22943912576d0b0e72858d8be926c709883bd657 /deps/npm/lib | |
parent | 36e90da6df56d6efeb12a38c1ed092eede4182a5 (diff) | |
download | node-c86afa5d2eeeb841f879fb4903484dabb769862a.tar.gz |
npm: Upgrade to 1.2.24
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/install.js | 17 | ||||
-rw-r--r-- | deps/npm/lib/shrinkwrap.js | 26 |
2 files changed, 40 insertions, 3 deletions
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 4db8d58ef..50ba5ebc5 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -250,6 +250,10 @@ function readDependencies (context, where, opts, cb) { }) } + // User has opted out of shrinkwraps entirely + if (npm.config.get("shrinkwrap") === false) + return cb(null, data, null) + if (wrap) { log.verbose("readDependencies: using existing wrap", [where, wrap]) var rv = {} @@ -288,6 +292,14 @@ function readDependencies (context, where, opts, cb) { Object.keys(newwrap.dependencies || {}).forEach(function (key) { rv.dependencies[key] = readWrap(newwrap.dependencies[key]) }) + + // fold in devDependencies if not already present, at top level + if (opts && opts.dev) { + Object.keys(data.devDependencies || {}).forEach(function (k) { + rv.dependencies[k] = rv.dependencies[k] || data.devDependencies[k] + }) + } + log.verbose("readDependencies returned deps", rv.dependencies) return cb(null, rv, newwrap.dependencies) }) @@ -568,7 +580,10 @@ function installMany (what, where, context, cb) { }) asyncMap(targets, function (target, cb) { log.info("installOne", target._id) - var newWrap = wrap ? wrap[target.name].dependencies || {} : null + var wrapData = wrap ? wrap[target.name] : null + var newWrap = wrapData && wrapData.dependencies + ? wrap[target.name].dependencies || {} + : null var newContext = { family: newPrev , ancestors: newAnc , parent: parent diff --git a/deps/npm/lib/shrinkwrap.js b/deps/npm/lib/shrinkwrap.js index e41f8cf63..14711df26 100644 --- a/deps/npm/lib/shrinkwrap.js +++ b/deps/npm/lib/shrinkwrap.js @@ -7,6 +7,7 @@ var npm = require("./npm.js") , log = require("npmlog") , fs = require("fs") , path = require("path") + , readJson = require("read-package-json") shrinkwrap.usage = "npm shrinkwrap" @@ -19,16 +20,37 @@ function shrinkwrap (args, silent, cb) { npm.commands.ls([], true, function (er, _, pkginfo) { if (er) return cb(er) - shrinkwrap_(pkginfo, silent, cb) + shrinkwrap_(pkginfo, silent, npm.config.get("dev"), cb) }) } -function shrinkwrap_ (pkginfo, silent, cb) { +function shrinkwrap_ (pkginfo, silent, dev, cb) { if (pkginfo.problems) { return cb(new Error("Problems were encountered\n" +"Please correct and try again.\n" +pkginfo.problems.join("\n"))) } + + if (!dev) { + // remove dev deps unless the user does --dev + readJson(path.resolve(npm.prefix, "package.json"), function (er, data) { + if (er) + return cb(er) + if (data.devDependencies) { + Object.keys(data.devDependencies).forEach(function (dep) { + log.warn("shrinkwrap", "Excluding devDependency: %s", dep) + delete pkginfo.dependencies[dep] + }) + } + save(pkginfo, silent, cb) + }) + } else { + save(pkginfo, silent, cb) + } +} + + +function save (pkginfo, silent, cb) { try { var swdata = JSON.stringify(pkginfo, null, 2) + "\n" } catch (er) { |