Skip to content

Commit

Permalink
Update npm fixes based on npm/cli#7025
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Nov 7, 2024
1 parent 4caa183 commit 3e2ada3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/shadow/arborist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type NodeClass = Omit<
new (...args: any): NodeClass
addEdgeIn(edge: SafeEdge): void
addEdgeOut(edge: SafeEdge): void
canDedupe(preferDedupe: boolean): boolean
canReplace(node: NodeClass, ignorePeers?: string[]): boolean
canReplaceWith(node: NodeClass, ignorePeers?: string[]): boolean
deleteEdgeIn(edge: SafeEdge): void
Expand Down Expand Up @@ -329,6 +330,15 @@ async function* batchScan(
}
}

// Patch adding doOverrideSetsConflict is based on
// https://github.com/npm/cli/pull/7025.
function doOverrideSetsConflict(
first: OverrideSetClass | undefined,
second: OverrideSetClass | undefined
) {
return findSpecificOverrideSet(first, second) === undefined
}

function findSocketYmlSync() {
let prevDir = null
let dir = process.cwd()
Expand Down Expand Up @@ -654,7 +664,7 @@ class SafeEdge extends Edge {
else if (
this.overrides &&
this.#safeTo.edgesOut.size &&
!findSpecificOverrideSet(this.overrides, this.#safeTo.overrides)
doOverrideSetsConflict(this.overrides, this.#safeTo.overrides)
) {
// Any inconsistency between the edge's override set and the target's
// override set is potentially problematic. But we only say the edge is
Expand Down Expand Up @@ -873,7 +883,7 @@ class SafeNode extends Node {
// Return true if it's safe to remove this node, because anything that is
// depending on it would be fine with the thing that they would resolve to if
// it was removed, or nothing is depending on it in the first place.
canDedupe(preferDedupe = false) {
override canDedupe(preferDedupe = false) {
// Not allowed to mess with shrinkwraps or bundles.
if (this.inDepBundle || this.inShrinkwrap) {
return false
Expand Down Expand Up @@ -1107,7 +1117,7 @@ class SafeNode extends Node {
}
// This is an error condition. We can only get here if the new override set
// is in conflict with the existing.
log!.silly(`Conflicting override requirements for node ${this.name}`, this)
log!.silly('Conflicting override sets', this.name)
return false
}

Expand Down

0 comments on commit 3e2ada3

Please sign in to comment.