Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2017-07-04 04:19:07 +0300
committerKat Marchán <kzm@sykosomatic.org>2017-07-06 01:11:02 +0300
commit9e5a943547b29c8d022192afd9398b3a136a7e5a (patch)
tree9e8bd55b4b1417a8a3e2cbd25de42602c324d90e /lib
parent06ba0a14a6c1c8cdcc8c062b68c8c63041b0cec0 (diff)
install/deps: Compute required package in legacy npm compatible way (#17590)
Not having this meant that uninstalls of globals installed by npm@4 or earlier would fail, due to _requested not having the fields we expected. PR-URL: https://github.com/npm/npm/pull/17590 Credit: @iarna Reviewed-By: @zkat
Diffstat (limited to 'lib')
-rw-r--r--lib/install/deps.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/install/deps.js b/lib/install/deps.js
index 5aa571303..35c35dbfd 100644
--- a/lib/install/deps.js
+++ b/lib/install/deps.js
@@ -254,11 +254,16 @@ exports.loadRequestedDeps = function (args, tree, saveToDependencies, log, next)
}, andForEachChild(loadDeps, andFinishTracker(log, next)))
}
+function isNotEmpty (value) {
+ return value != null && value !== ''
+}
+
module.exports.computeVersionSpec = computeVersionSpec
function computeVersionSpec (tree, child) {
validate('OO', arguments)
var requested
- if (child.package._requested) {
+ var childReq = child.package._requested
+ if (childReq && (isNotEmpty(childReq.saveSpec) || (isNotEmpty(childReq.rawSpec) && isNotEmpty(childReq.fetchSpec)))) {
requested = child.package._requested
} else if (child.package._from) {
requested = npa(child.package._from)
@@ -277,7 +282,7 @@ function computeVersionSpec (tree, child) {
} else if (requested.type === 'directory' || requested.type === 'file') {
return 'file:' + path.relative(tree.path, requested.fetchSpec)
} else {
- return requested.saveSpec
+ return requested.saveSpec || requested.rawSpec
}
}