diff options
author | isaacs <i@izs.me> | 2011-04-27 20:52:35 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-04-27 20:52:35 +0400 |
commit | 1b593e9e5e20718b134d35f228dbd8d11b182f38 (patch) | |
tree | 7a0d55db9093d77922b45f522c423cbf9960af31 | |
parent | a77919a7cc3ace6717a88e5038a9dddd0c1effd0 (diff) |
Run preinstall before installing dependencies
-rw-r--r-- | lib/build.js | 5 | ||||
-rw-r--r-- | lib/install.js | 7 | ||||
-rw-r--r-- | lib/link.js | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/build.js b/lib/build.js index e3cdf332c..ca8f6d6f3 100644 --- a/lib/build.js +++ b/lib/build.js @@ -23,7 +23,8 @@ var npm = require("../npm") module.exports = build build.usage = "npm build <folder>\n(this is plumbing)" -function build (args, global, cb) { +function build (args, global, didPreinstall, cb) { + if (typeof cb !== "function") cb = didPreinstall, didPreinstall = false if (typeof cb !== "function") cb = global, global = npm.config.get("global") asyncMap(args, build_(global), cb) } @@ -34,7 +35,7 @@ function build_ (global) { return function (folder, cb) { readJson(path.resolve(folder, "package.json"), function (er, pkg) { if (er) return cb(er) chain - ( [lifecycle, pkg, "preinstall", folder] + ( !didPreinstall && [lifecycle, pkg, "preinstall", folder] , [linkStuff, pkg, folder, global] , [lifecycle, pkg, "install", folder] , [lifecycle, pkg, "postinstall", folder] diff --git a/lib/install.js b/lib/install.js index 6f36aa82e..c420348ad 100644 --- a/lib/install.js +++ b/lib/install.js @@ -144,6 +144,7 @@ var npm = require("../npm") , output , url = require("url") , mkdir = require("./utils/mkdir-p") + , lifecycle = require("./utils/lifecycle") function install (args, cb) { @@ -432,6 +433,7 @@ function write (target, targetFolder, previously, cb_) { ( [ npm.commands.unbuild, [targetFolder] ] , [ cache.unpack, target.name, target.version, targetFolder , null, null, user, group ] + , [ lifecycle, target, "preinstall", targetFolder ] , function (cb) { var deps = Object.keys(target.dependencies || {}) installMany(deps.filter(function (d) { @@ -447,7 +449,10 @@ function write (target, targetFolder, previously, cb_) { }), targetFolder, previously, false, function (er) { log.verbose(targetFolder, "about to build") if (er) return cb(er) - npm.commands.build([targetFolder], cb) + npm.commands.build( [targetFolder] + , npm.config.get("global") + , true + , cb ) }) } , cb ) diff --git a/lib/link.js b/lib/link.js index f5099dc48..3829bc4ea 100644 --- a/lib/link.js +++ b/lib/link.js @@ -112,7 +112,9 @@ function linkPkg (folder, cb_) { // also install missing dependencies. npm.commands.install(me, [], function (er, installed) { if (er) return cb(er) - npm.commands.build([target], true, function (er) { + // build the global stuff. Don't run preinstall, because + // install command already will have done that. + npm.commands.build([target], true, true, function (er) { if (er) return cb(er) resultPrinter(path.basename(me), me, target, cb) }) |