diff options
author | Rebecca Turner <me@re-becca.org> | 2015-10-10 02:17:18 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-10-23 01:28:01 +0300 |
commit | e47eed21d8ec6cec8aa61760a19baa9279fcf3c3 (patch) | |
tree | 86846d029941e41d43b3af4090e6af1708c3b1c2 /lib | |
parent | 5ee1491c13053370948ba972fd02e91c541a428a (diff) |
deps: Refactor module matchers into stand alone functions
PR-URL: https://github.com/npm/npm/pull/9929
Diffstat (limited to 'lib')
-rw-r--r-- | lib/install/deps.js | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js index d001136a5..2c8647ff1 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -209,6 +209,10 @@ exports.loadRequestedDeps = function (args, tree, saveToDependencies, log, next) }, andForEachChild(loadDeps, andFinishTracker(log, next))) } +function noModuleNameMatches (name) { + return function (child) { return moduleName(child) !== name } +} + // while this implementation does not require async calling, doing so // gives this a consistent interface with loadDeps et al exports.removeDeps = function (args, tree, saveToDependencies, log, next) { @@ -222,7 +226,7 @@ exports.removeDeps = function (args, tree, saveToDependencies, log, next) { parent.save = saveToDependencies }) } - tree.children = tree.children.filter(function (child) { return moduleName(child) !== pkgName }) + tree.children = tree.children.filter(noModuleNameMatches(pkgName)) }) log.finish() next() @@ -264,7 +268,7 @@ var failedDependency = exports.failedDependency = function (tree, name_pkg) { name = moduleName(pkg) } - tree.children = tree.children.filter(function (child) { return moduleName(child) !== name }) + tree.children = tree.children.filter(noModuleNameMatches(name)) if (isDepOptional(tree, name)) { return false @@ -290,7 +294,7 @@ function andHandleOptionalErrors (log, tree, name, done) { if (!er) return done(er, child, childLog) var isFatal = failedDependency(tree, name) if (er && !isFatal) { - tree.children = tree.children.filter(function (child) { return moduleName(child) !== name }) + tree.children = tree.children.filter(noModuleNameMatches(name)) log.warn('install', "Couldn't install optional dependency:", er.message) log.verbose('install', er.stack) return done() |