Skip to content

Commit e83ca91

Browse files
committed
fix(arborist): inherit overrides from fsParent
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.
1 parent 5e234ad commit e83ca91

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

workspaces/arborist/lib/node.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,12 @@ class Node {
822822
target.root = root
823823
}
824824

825-
if (!this.overrides && this.parent && this.parent.overrides) {
826-
this.overrides = this.parent.overrides.getNodeRule(this)
825+
if (!this.overrides) {
826+
if (this.parent && this.parent.overrides) {
827+
this.overrides = this.parent.overrides.getNodeRule(this)
828+
} else if (this.fsParent && this.fsParent.overrides) {
829+
this.overrides = this.fsParent.overrides.getNodeRule(this)
830+
}
827831
}
828832
// tree should always be valid upon root setter completion.
829833
treeCheck(this)

workspaces/arborist/tap-snapshots/test/arborist/load-virtual.js.test.cjs

+5-2
Original file line numberDiff line numberDiff line change
@@ -16381,9 +16381,9 @@ ArboristNode {
1638116381
"arg" => ArboristNode {
1638216382
"edgesIn": Set {
1638316383
EdgeIn {
16384-
"error": "INVALID",
1638516384
"from": "ws",
1638616385
"name": "arg",
16386+
"override": "4.1.3",
1638716387
"spec": "4.1.2",
1638816388
"type": "prod",
1638916389
},
@@ -16433,8 +16433,8 @@ ArboristNode {
1643316433
ArboristNode {
1643416434
"edgesOut": Map {
1643516435
"arg" => EdgeOut {
16436-
"error": "INVALID",
1643716436
"name": "arg",
16437+
"override": "4.1.3",
1643816438
"spec": "4.1.2",
1643916439
"to": "node_modules/arg",
1644016440
"type": "prod",
@@ -16443,6 +16443,9 @@ ArboristNode {
1644316443
"isWorkspace": true,
1644416444
"location": "ws",
1644516445
"name": "ws",
16446+
"overrides": Map {
16447+
"arg" => "4.1.3",
16448+
},
1644616449
"path": "{CWD}/test/fixtures/workspaces-with-overrides/ws",
1644716450
"version": "1.0.0",
1644816451
},

workspaces/arborist/tap-snapshots/test/arborist/reify.js.test.cjs

+6-6
Original file line numberDiff line numberDiff line change
@@ -53512,19 +53512,19 @@ Object {
5351253512
"link": true,
5351353513
"resolved": "ws",
5351453514
},
53515+
"node_modules/arg": Object {
53516+
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
53517+
"license": "MIT",
53518+
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
53519+
"version": "4.1.3",
53520+
},
5351553521
"ws": Object {
5351653522
"dependencies": Object {
5351753523
"arg": "4.1.2",
5351853524
},
5351953525
"name": "a",
5352053526
"version": "1.0.0",
5352153527
},
53522-
"ws/node_modules/arg": Object {
53523-
"integrity": "sha512-+ytCkGcBtHZ3V2r2Z06AncYO8jz46UEamcspGoU8lHcEbpn6J77QK0vdWvChsclg/tM5XIJC5tnjmPp7Eq6Obg==",
53524-
"license": "MIT",
53525-
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.2.tgz",
53526-
"version": "4.1.2",
53527-
},
5352853528
},
5352953529
"requires": true,
5353053530
}

0 commit comments

Comments
 (0)