Browse files

Install missing deps, even if they are in bundleDependencies

  • Loading branch information...
1 parent 0c29a0f commit 449c522f874126d7d5cf16eb936c9d7ee86e7adc @isaacs isaacs committed Mar 12, 2012
Showing with 18 additions and 4 deletions.
  1. +18 −4 lib/install.js
View
22 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
})
}

0 comments on commit 449c522

Please sign in to comment.