Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/lib/arborist/build-ideal-tree.js b/lib/arborist/build-ideal-tree.js
index 78192cdd..49b21ca2 100644
--- a/lib/arborist/build-ideal-tree.js
+++ b/lib/arborist/build-ideal-tree.js
@@ -1647,12 +1647,34 @@ This is a one-time fix-up, please be patient...
// to get the conflict here so that we can decide whether to
// accept the current dep node, clobber it, or fail the install.
if (edge.from === target && edge.valid) {
+ // replacement from virtual root
const rep = dep.parent.children.get(edge.name)
- const override = rep && ([...rep.edgesIn].some(e => !e.valid))
- if (!rep || !rep.satisfies(edge) || override) {
- canReplace = false
- break OUTER
+ // not going to replace it, so make sure it won't cause problems
+ // if the things we ARE replacing are going to break the edges
+ // for the thing that has to be here, then it's a conflict.
+ if (!rep) {
+ const current = edge.to
+ for (const repEdge of current.edgesOut.values()) {
+ const newRepDep = dep.parent.children.get(repEdge.name)
+ if (repEdge.valid && newRepDep && !newRepDep.satisfies(repEdge)) {
+ canReplace = false
+ break OUTER
+ }
+ }
+ continue
}
+
+ // was said replacement an override already?
+ const override = [...rep.edgesIn].some(e => !e.valid)
+ // if we have a rep, and it's ok to put in this location, and
+ // it's not already part of an override in the peerSet, then
+ // we can continue with it.
+ if (rep.satisfies(edge) && !override)
+ continue
+
+ // Otherwise, we cannot replace.
+ canReplace = false
+ break OUTER
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment