From c8cf71de6c56a826a10525d880c179f814a5f368 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Mon, 21 Nov 2016 15:19:45 -0800 Subject: deps: upgrade npm to 3.10.10 PR-URL: https://github.com/nodejs/node/pull/9847 Reviewed-By: Jeremiah Senkpiel --- deps/npm/lib/install/deps.js | 8 +++++--- deps/npm/lib/install/inflate-shrinkwrap.js | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'deps/npm/lib') diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js index 4d315ab188..d7081296db 100644 --- a/deps/npm/lib/install/deps.js +++ b/deps/npm/lib/install/deps.js @@ -326,14 +326,16 @@ function andForEachChild (load, next) { } } -function isDepOptional (tree, name) { +function isDepOptional (tree, name, pkg) { + if (pkg.package && pkg.package._optional) return true if (!tree.package.optionalDependencies) return false if (tree.package.optionalDependencies[name] != null) return true return false } var failedDependency = exports.failedDependency = function (tree, name_pkg) { - var name, pkg + var name + var pkg = {} if (typeof name_pkg === 'string') { name = name_pkg } else { @@ -342,7 +344,7 @@ var failedDependency = exports.failedDependency = function (tree, name_pkg) { } tree.children = tree.children.filter(noModuleNameMatches(name)) - if (isDepOptional(tree, name)) { + if (isDepOptional(tree, name, pkg)) { return false } diff --git a/deps/npm/lib/install/inflate-shrinkwrap.js b/deps/npm/lib/install/inflate-shrinkwrap.js index ab1bdd1f19..b70e9576bf 100644 --- a/deps/npm/lib/install/inflate-shrinkwrap.js +++ b/deps/npm/lib/install/inflate-shrinkwrap.js @@ -45,14 +45,16 @@ function inflateShrinkwrap (topPath, tree, swdeps, finishInflating) { return inflateShrinkwrap(topPath, child, dependencies || {}, next) } else { var from = sw.from || requested.raw - return fetchPackageMetadata(requested, topPath, iferr(next, andAddShrinkwrap(from, dependencies, next))) + var optional = sw.optional + return fetchPackageMetadata(requested, topPath, iferr(next, andAddShrinkwrap(from, optional, dependencies, next))) } } } - function andAddShrinkwrap (from, dependencies, next) { + function andAddShrinkwrap (from, optional, dependencies, next) { return function (pkg) { pkg._from = from + pkg._optional = optional addShrinkwrap(pkg, iferr(next, andAddBundled(pkg, dependencies, next))) } } -- cgit v1.2.1