diff options
Diffstat (limited to 'deps/npm/lib/install.js')
-rw-r--r-- | deps/npm/lib/install.js | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 1fb5a4f4e6..4c3d0def78 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -1,8 +1,8 @@ 'use strict' // npm install <pkg> <pkg> <pkg> // -// See doc/install.md for more description - +// See doc/cli/npm-install.md for more description +// // Managing contexts... // there's a lot of state associated with an "install" operation, including // packages that are already installed, parent packages, current shrinkwrap, and @@ -259,6 +259,9 @@ Installer.prototype.run = function (cb) { [this, this.debugActions, 'decomposeActions', 'todo']) if (!this.dryrun) { installSteps.push( + [this.newTracker(log, 'runTopLevelLifecycles', 2)], + [this, this.runPreinstallTopLevelLifecycles], + [this.newTracker(log, 'executeActions', 8)], [this, this.executeActions], [this, this.finishTracker, 'executeActions']) @@ -269,10 +272,9 @@ Installer.prototype.run = function (cb) { [this, this.rollbackFailedOptional, staging, this.todo], [this, this.finishTracker, 'rollbackFailedOptional'], [this, this.commit, staging, this.todo], - [this.newTracker(log, 'runTopLevelLifecycles', 2)], - [this, this.runTopLevelLifecycles], - [this, this.finishTracker, 'runTopLevelLifecycles']) + [this, this.runPostinstallTopLevelLifecycles], + [this, this.finishTracker, 'runTopLevelLifecycles']) if (getSaveType(this.args)) { postInstallSteps.push( [this, this.saveToDependencies]) @@ -289,9 +291,13 @@ Installer.prototype.run = function (cb) { self.idealTree.warnings.forEach(function (warning) { if (warning.code === 'EPACKAGEJSON' && self.global) return if (warning.code === 'ENOTDIR') return - errorMessage(warning).summary.forEach(function (logline) { + var output = errorMessage(warning) + output.summary.forEach(function (logline) { log.warn.apply(log, logline) }) + output.detail.forEach(function (logline) { + log.verbose.apply(log, logline) + }) }) } if (installEr && postInstallEr) { @@ -310,7 +316,7 @@ Installer.prototype.run = function (cb) { Installer.prototype.loadArgMetadata = function (next) { var self = this - getAllMetadata(this.args, this.currentTree, iferr(next, function (args) { + getAllMetadata(this.args, this.currentTree, process.cwd(), iferr(next, function (args) { self.args = args next() })) @@ -520,19 +526,29 @@ Installer.prototype.commit = function (staging, actionsToRun, cb) { }, cb) } -Installer.prototype.runTopLevelLifecycles = function (cb) { +Installer.prototype.runPreinstallTopLevelLifecycles = function (cb) { validate('F', arguments) if (this.failing) return cb() - log.silly('install', 'runTopLevelLifecycles') + if (!this.topLevelLifecycles) return cb() + log.silly('install', 'runPreinstallTopLevelLifecycles') + var steps = [] + var trackLifecycle = this.progress.runTopLevelLifecycles + + steps.push( + [doOneAction, 'preinstall', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('preinstall:.')] + ) + chain(steps, cb) +} + +Installer.prototype.runPostinstallTopLevelLifecycles = function (cb) { + validate('F', arguments) + if (this.failing) return cb() + if (!this.topLevelLifecycles) return cb() + log.silly('install', 'runPostinstallTopLevelLifecycles') var steps = [] var trackLifecycle = this.progress.runTopLevelLifecycles - if (!this.topLevelLifecycles) { - trackLifecycle.finish() - return cb() - } steps.push( - [doOneAction, 'preinstall', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('preinstall:.')], [doOneAction, 'build', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('build:.')], [doOneAction, 'install', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('install:.')], [doOneAction, 'postinstall', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('postinstall:.')]) @@ -591,18 +607,19 @@ Installer.prototype.readLocalPackageData = function (cb) { return cb(er) } if (!currentTree.package) currentTree.package = {} - self.loadArgMetadata(iferr(cb, function () { - if (currentTree.package._shrinkwrap) return cb() + if (currentTree.package._shrinkwrap) { + self.loadArgMetadata(cb) + } else { fs.readFile(path.join(self.where, 'npm-shrinkwrap.json'), function (er, data) { - if (er) return cb() + if (er) return self.loadArgMetadata(cb) try { currentTree.package._shrinkwrap = parseJSON(data) } catch (ex) { return cb(ex) } - return cb() + return self.loadArgMetadata(cb) }) - })) + } })) })) } |