diff options
Diffstat (limited to 'deps/npm/lib/install')
-rw-r--r-- | deps/npm/lib/install/deps.js | 8 | ||||
-rw-r--r-- | deps/npm/lib/install/inflate-shrinkwrap.js | 6 |
2 files changed, 9 insertions, 5 deletions
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))) } } |