diff options
author | Rebecca Turner <me@re-becca.org> | 2015-05-14 08:07:21 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-06-26 03:26:57 +0300 |
commit | 14c154257d8add4eea1df85d217a274fbf44efc9 (patch) | |
tree | b6eb6efcecae97dcc8756d75063934395fc13a16 /lib/install.js | |
parent | fd88e678a1eae06873ce16c9f0ef5d9f6a54a9bf (diff) |
Start recording warnings in the tree and only print them at the end
Diffstat (limited to 'lib/install.js')
-rw-r--r-- | lib/install.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/lib/install.js b/lib/install.js index 65e3605d1..29e44601f 100644 --- a/lib/install.js +++ b/lib/install.js @@ -234,7 +234,13 @@ Installer.prototype.run = function (cb) { steps.push( [this, this.printInstalled]) - chain(steps, cb) + var self = this + chain(steps, function (er) { + self.idealTree.warnings.forEach(function (warning) { + log.warn(warning.code, warning.message) + }) + cb(er, self.idealTree) + }) } Installer.prototype.newTracker = function (tracker, name, size) { @@ -407,25 +413,26 @@ Installer.prototype.readLocalPackageData = function (cb) { var self = this mkdirp(this.where, iferr(cb, function () { readPackageTree(self.where, iferr(cb, function (currentTree) { - self.currentTree = currentTree - if (!self.noPackageJsonOk && !currentTree.package) { + self.currentTree = currentTree + self.currentTree.warnings = [] + if (!self.noPackageJsonOk && !currentTree.package) { log.error('install', "Couldn't read dependencies") var er = new Error("ENOENT, open '" + path.join(self.where, 'package.json') + "'") er.code = 'ENOPACKAGEJSON' er.errno = 34 return cb(er) - } - if (!currentTree.package) currentTree.package = {} - if (currentTree.package._shrinkwrap) return cb() - fs.readFile(path.join(self.where, 'npm-shrinkwrap.json'), {encoding: 'utf8'}, function (er, data) { + } + if (!currentTree.package) currentTree.package = {} + if (currentTree.package._shrinkwrap) return cb() + fs.readFile(path.join(self.where, 'npm-shrinkwrap.json'), {encoding: 'utf8'}, function (er, data) { if (er) return cb() try { - currentTree.package._shrinkwrap = JSON.parse(data) + currentTree.package._shrinkwrap = JSON.parse(data) } catch (ex) { - return cb(ex) + return cb(ex) } return cb() - }) + }) })) })) @@ -435,6 +442,7 @@ Installer.prototype.cloneCurrentTreeToIdealTree = function (cb) { validate('F', arguments) log.silly('install', 'cloneCurrentTreeToIdealTree') this.idealTree = clone(this.currentTree) + this.idealTree.warnings = [] cb() } @@ -490,8 +498,10 @@ Installer.prototype.printInstalled = function (cb) { if (!addedOrMoved.length) return cb() recalculateMetadata(this.idealTree, log, iferr(cb, function (tree) { log.clearProgress() - ls.fromTree(self.where, tree, addedOrMoved, false, cb) - log.showProgress() + ls.fromTree(self.where, tree, addedOrMoved, false, function () { + log.showProgress() + cb() + }) })) } |