Permalink
Browse files

Run the build process on top-level dir for implicit install

  • Loading branch information...
1 parent a9fcb63 commit f32af473723d4227b5ebd8534323524c5183839b @isaacs isaacs committed Apr 20, 2011
Showing with 12 additions and 4 deletions.
  1. +4 −2 lib/build.js
  2. +8 −2 lib/install.js
View
6 lib/build.js
@@ -96,9 +96,11 @@ function rebuildBundles (pkg, folder, parent, gtop, cb) {
}
function linkBins (pkg, folder, parent, gtop, cb) {
- if (!pkg.bin) return cb()
+ if (!pkg.bin || !gtop && path.basename(parent) !== "node_modules") {
+ return cb()
+ }
var binRoot = gtop ? path.resolve(npm.config.get("prefix"), "bin")
- : path.resolve(parent, ".bin")
+ : path.resolve(parent, ".bin")
log.verbose([pkg.bin, binRoot], "bins linking")
asyncMap(Object.keys(pkg.bin), function (b, cb) {
linkIfExists(path.resolve(folder, pkg.bin[b])
View
10 lib/install.js
@@ -175,7 +175,6 @@ function install (args, cb) {
if (er) return log.er(cb, "Couldn't read dependencies.")(er)
var deps = Object.keys(data.dependencies || {})
log.verbose([where, deps], "where, deps")
- if (!deps.length) return log("Nothing to do", "install", cb)
var previously = {}
previously[data.name] = data.version
installManyTop(deps.map(function (dep) {
@@ -230,7 +229,14 @@ function installManyTop (what, where, previously, explicit, cb) {
packages.forEach(function (p) {
previously[p[0]] = p[1]
})
- return installMany(what, where, previously, explicit, cb)
+ return installMany(what, where, previously, explicit, function (er, d) {
+ if (explicit || er) return cb(er, d)
+ // since this wasn't an explicit install, let's build the top
+ // folder, so that `npm install` also runs the lifecycle scripts.
+ npm.commands.build([where], function (er) {
+ return cb(er, d)
+ })
+ })
})
})
}

0 comments on commit f32af47

Please sign in to comment.