Skip to content

Commit

Permalink
fix(arborist): inherit overrides from fsParent
Browse files Browse the repository at this point in the history
Fixes #4205

In the virtual tree, workspace nodes are `fsChildren` of the root, not
`children`. As a result, they weren't inheriting the root's overrides,
causing those overrides to be ignored for all dependencies of
workspaces. The fix here is to inherit `fsParent.overrides` whenever
possible.
  • Loading branch information
TrevorBurnham committed Feb 14, 2025
1 parent 83b95d5 commit 6d5d51e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions workspaces/arborist/lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,12 @@ class Node {
target.root = root
}

if (!this.overrides && this.parent && this.parent.overrides) {
this.overrides = this.parent.overrides.getNodeRule(this)
if (!this.overrides) {
if (this.parent && this.parent.overrides) {
this.overrides = this.parent.overrides.getNodeRule(this)
} else if (this.fsParent && this.fsParent.overrides) {
this.overrides = this.fsParent.overrides.getNodeRule(this)
}
}
// tree should always be valid upon root setter completion.
treeCheck(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16381,9 +16381,9 @@ ArboristNode {
"arg" => ArboristNode {
"edgesIn": Set {
EdgeIn {
"error": "INVALID",
"from": "ws",
"name": "arg",
"override": "4.1.3",
"spec": "4.1.2",
"type": "prod",
},
Expand Down Expand Up @@ -16433,8 +16433,8 @@ ArboristNode {
ArboristNode {
"edgesOut": Map {
"arg" => EdgeOut {
"error": "INVALID",
"name": "arg",
"override": "4.1.3",
"spec": "4.1.2",
"to": "node_modules/arg",
"type": "prod",
Expand All @@ -16443,6 +16443,9 @@ ArboristNode {
"isWorkspace": true,
"location": "ws",
"name": "ws",
"overrides": Map {
"arg" => "4.1.3",
},
"path": "{CWD}/test/fixtures/workspaces-with-overrides/ws",
"version": "1.0.0",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53512,19 +53512,19 @@ Object {
"link": true,
"resolved": "ws",
},
"node_modules/arg": Object {
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
"license": "MIT",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
"version": "4.1.3",
},
"ws": Object {
"dependencies": Object {
"arg": "4.1.2",
},
"name": "a",
"version": "1.0.0",
},
"ws/node_modules/arg": Object {
"integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==",
"license": "MIT",
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz",
"version": "4.1.2",
},
},
"requires": true,
}
Expand Down

0 comments on commit 6d5d51e

Please sign in to comment.