Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
deps: Add failed optional deps warnings to tree obj
Browse files Browse the repository at this point in the history
The top level tree holds on to warnings that occured while it was being
generated to be emitted later. This makes it so that optional dependency
failures are treated this way.

Credit: @iarna
PR-URL: #10465
Reviewed By: @othiym23
Fixes: #9204
  • Loading branch information
iarna committed Nov 20, 2015
1 parent f5f166f commit b726a0e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/install/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,18 @@ var failedDependency = exports.failedDependency = function (tree, name_pkg) {
return false
}

function top (tree) {
if (tree.parent) return top(tree.parent)
return tree
}

function treeWarn (tree, what, error) {
var topTree = top(tree)
if (!topTree.warnings) topTree.warnings = []
error.optional = flatNameFromTree(tree) + '/' + what
topTree.warnings.push(error)
}

function andHandleOptionalErrors (log, tree, name, done) {
validate('OOSF', arguments)
return function (er, child, childLog) {
Expand All @@ -305,8 +317,7 @@ function andHandleOptionalErrors (log, tree, name, done) {
var isFatal = failedDependency(tree, name)
if (er && !isFatal) {
tree.children = tree.children.filter(noModuleNameMatches(name))
log.warn('install', "Couldn't install optional dependency:", er.message)
log.verbose('install', er.stack)
treeWarn(tree, name, er)
return done()
} else {
return done(er, child, childLog)
Expand Down

0 comments on commit b726a0e

Please sign in to comment.