diff options
author | isaacs <i@izs.me> | 2012-03-13 06:32:12 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-13 06:32:12 +0400 |
commit | 449c522f874126d7d5cf16eb936c9d7ee86e7adc (patch) | |
tree | 4e59dc02d4c8f862abc489304e3dd87801e55276 | |
parent | 0c29a0f934b6f1dbff1f2b2a724690cc2e9bfbe6 (diff) |
Install missing deps, even if they are in bundleDependencies
-rw-r--r-- | lib/install.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/install.js b/lib/install.js index e92ef67a2..f8d8201f3 100644 --- a/lib/install.js +++ b/lib/install.js @@ -722,27 +722,41 @@ function write (target, targetFolder, context, cb_) { }) } + var bundled = [] + chain ( [ [ cache.unpack, target.name, target.version, targetFolder , null, null, user, group ] , [ fs, "writeFile" , path.resolve(targetFolder, "package.json") , JSON.stringify(target, null, 2) + "\n" ] - , [ lifecycle, target, "preinstall", targetFolder ] ] + , [ lifecycle, target, "preinstall", targetFolder ] + , function (cb) { + if (!target.bundleDependencies) return cb() + + var bd = path.resolve(targetFolder, "node_modules") + fs.readdir(bd, function (er, b) { + // nothing bundled, maybe + if (er) return cb() + bundled = b || [] + cb() + }) + } ] // nest the chain so that we can throw away the results returned // up until this point, since we really don't care about it. - , function (er) { + , function X (er) { if (er) return cb(er) // before continuing to installing dependencies, check for a shrinkwrap. readDependencies(context, targetFolder, {}, function (er, data, wrap) { var deps = Object.keys(data.dependencies || {}) - // don't install bundleDependencies + // don't install bundleDependencies, unless they're missing. if (data.bundleDependencies) { deps = deps.filter(function (d) { - return data.bundleDependencies.indexOf(d) === -1 + return data.bundleDependencies.indexOf(d) === -1 || + bundled.indexOf(d) === -1 }) } |