Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-08-01 21:11:55 +0300
committerGitHub <noreply@github.com>2022-08-01 21:11:55 +0300
commit47cc95d9ffb37fc8ff62a1d5554eab16d303aa43 (patch)
treee223c5a34162e567d930d3989dd888b58bdaec37 /workspaces/arborist/lib
parenta6153cfd2b0764e69d103b33af6b42978b0403f4 (diff)
fix(arborist): use the sourceReference root rather than the node root for overrides (#5227)
when we examine override references, if we look at only `this.from.root.package` the root could actually be a virtual one. in order to ensure we resolve references from the real root, we instead need to look at `this.from.sourceReference.root.package` to get the correct value. closes #4395
Diffstat (limited to 'workspaces/arborist/lib')
-rw-r--r--workspaces/arborist/lib/edge.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/workspaces/arborist/lib/edge.js b/workspaces/arborist/lib/edge.js
index a04404f22..5b248b916 100644
--- a/workspaces/arborist/lib/edge.js
+++ b/workspaces/arborist/lib/edge.js
@@ -169,7 +169,11 @@ class Edge {
if (this.overrides && this.overrides.value && this.overrides.name === this.name) {
if (this.overrides.value.startsWith('$')) {
const ref = this.overrides.value.slice(1)
- const pkg = this.from.root.package
+ // we may be a virtual root, if we are we want to resolve reference overrides
+ // from the real root, not the virtual one
+ const pkg = this.from.sourceReference
+ ? this.from.sourceReference.root.package
+ : this.from.root.package
const overrideSpec = (pkg.devDependencies && pkg.devDependencies[ref]) ||
(pkg.optionalDependencies && pkg.optionalDependencies[ref]) ||
(pkg.dependencies && pkg.dependencies[ref]) ||