Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Install missing deps, even if they are in bundleDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Mar 13, 2012
1 parent 0c29a0f commit 449c522
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/install.js
Expand Up @@ -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
})
}

Expand Down

0 comments on commit 449c522

Please sign in to comment.