Created
October 13, 2021 21:04
-
-
Save isaacs/eb4bfc298aefa3168bf366d7133039a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/@npmcli/arborist/lib/can-place-dep.js b/node_modules/@npmcli/arborist/lib/can-place-dep.js | |
index 6be59093c..3291b6fbf 100644 | |
--- a/node_modules/@npmcli/arborist/lib/can-place-dep.js | |
+++ b/node_modules/@npmcli/arborist/lib/can-place-dep.js | |
@@ -145,7 +145,9 @@ class CanPlaceDep { | |
return CONFLICT | |
} | |
- if (targetEdge && !dep.satisfies(targetEdge) && targetEdge !== this.edge) { | |
+ // skip this test if there's a current node, because we might be able | |
+ // to dedupe against it anyway | |
+ if (!current && targetEdge && !dep.satisfies(targetEdge) && targetEdge !== this.edge) { | |
return CONFLICT | |
} | |
@@ -167,10 +169,10 @@ class CanPlaceDep { | |
const { version: newVer } = dep | |
const tryReplace = curVer && newVer && semver.gte(newVer, curVer) | |
if (tryReplace && dep.canReplace(current)) { | |
- /* XXX-istanbul ignore else - It's extremely rare that a replaceable | |
- * node would be a conflict, if the current one wasn't a conflict, | |
- * but it is theoretically possible if peer deps are pinned. In | |
- * that case we treat it like any other conflict, and keep trying */ | |
+ // It's extremely rare that a replaceable node would be a conflict, if | |
+ // the current one wasn't a conflict, but it is theoretically possible | |
+ // if peer deps are pinned. In that case we treat it like any other | |
+ // conflict, and keep trying. | |
const cpp = this.canPlacePeers(REPLACE) | |
if (cpp !== CONFLICT) { | |
return cpp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment