diff options
Diffstat (limited to 'lib/install.js')
-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 }) } |