Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-05-25 04:02:26 +0300
committerRebecca Turner <me@re-becca.org>2017-05-26 04:55:29 +0300
commit0cc5517adc388e776880e436b6e1a9e2d6768db7 (patch)
treec447219d13127bac18c4b4aa2779336d1e43846f /lib
parentcd7a5d044ae7ebfd2632b45dbc49acb63232153f (diff)
install: Run preinstall prior to reading the tree
Diffstat (limited to 'lib')
-rw-r--r--lib/install.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/install.js b/lib/install.js
index 20d3d0f96..cd64dc805 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -98,6 +98,7 @@ var path = require('path')
// dependencies
var log = require('npmlog')
var readPackageTree = require('read-package-tree')
+var readPackageJson = require('read-package-json')
var chain = require('slide').chain
var asyncMap = require('slide').asyncMap
var archy = require('archy')
@@ -245,6 +246,11 @@ Installer.prototype.run = function (_cb) {
var installSteps = []
var postInstallSteps = []
+ if (!this.dryrun) {
+ installSteps.push(
+ [this.newTracker(log, 'runTopLevelLifecycles', 2)],
+ [this, this.runPreinstallTopLevelLifecycles])
+ }
installSteps.push(
[this.newTracker(log, 'loadCurrentTree', 4)],
[this, this.loadCurrentTree],
@@ -265,9 +271,6 @@ 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'])
@@ -551,10 +554,15 @@ Installer.prototype.runPreinstallTopLevelLifecycles = function (cb) {
var steps = []
var trackLifecycle = this.progress.runTopLevelLifecycles
- steps.push(
- [doOneAction, 'preinstall', this.idealTree.path, this.idealTree, trackLifecycle.newGroup('preinstall:.')]
- )
- chain(steps, cb)
+ readPackageJson(path.join(this.where, 'package.json'), log, false, (err, data) => {
+ if (err) return cb()
+ this.currentTree = createNode({
+ isTop: true,
+ package: data,
+ path: this.where
+ })
+ doOneAction('preinstall', this.where, this.currentTree, log.newGroup('preinstall:.'), cb)
+ })
}
Installer.prototype.runPostinstallTopLevelLifecycles = function (cb) {