diff options
Diffstat (limited to 'lib/install')
-rw-r--r-- | lib/install/deps.js | 13 | ||||
-rw-r--r-- | lib/install/is-extraneous.js | 10 |
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js index 368e25030..cc6420ee0 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -258,9 +258,17 @@ exports.loadRequestedDeps = function (args, tree, saveToDependencies, log, next) }, andForEachChild(loadDeps, andFinishTracker(log, next))) } +module.exports.computeVersionSpec = computeVersionSpec function computeVersionSpec (tree, child) { validate('OO', arguments) - var requested = child.package._requested + var requested + if (child.package._requested) { + requested = child.package._requested + } else if (child.package._from) { + requested = npa(child.package._from) + } else { + requested = npa.resolve(child.package.name, child.package.version) + } if (requested.registry) { var version = child.package.version var rangeDescriptor = '' @@ -310,6 +318,9 @@ exports.removeDeps = function (args, tree, saveToDependencies, next) { replaceModuleByPath(tree, 'removedChildren', pkgToRemove) } } + for (let parent of pkgToRemove.requiredBy) { + parent.requires = parent.requires.filter((child) => child !== pkgToRemove) + } pkgToRemove.requiredBy = pkgToRemove.requiredBy.filter((parent) => parent !== tree) } next() diff --git a/lib/install/is-extraneous.js b/lib/install/is-extraneous.js index f0d599965..a6477c237 100644 --- a/lib/install/is-extraneous.js +++ b/lib/install/is-extraneous.js @@ -6,14 +6,6 @@ function isExtraneous (tree) { return result } -function isNotRequired (tree) { - return tree.requiredBy && tree.requiredBy.length === 0 -} - -function parentHasNoPjson (tree) { - return tree.parent && tree.parent.isTop && tree.parent.error -} - function topHasNoPjson (tree) { var top = tree while (!top.isTop) top = top.parent @@ -24,8 +16,6 @@ function isNotExtraneous (tree, isCycle) { if (!isCycle) isCycle = {} if (tree.isTop || tree.userRequired) { return true - } else if (isNotRequired(tree) && parentHasNoPjson(tree)) { - return true } else if (isCycle[tree.path]) { return topHasNoPjson(tree) } else { |