Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 13, 2021 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/eb4bfc298aefa3168bf366d7133039a1 to your computer and use it in GitHub Desktop.
Save isaacs/eb4bfc298aefa3168bf366d7133039a1 to your computer and use it in GitHub Desktop.
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