Skip to content

Commit

Permalink
fix: make sure we loadOverrides on the root node in loadVirtual()
Browse files Browse the repository at this point in the history
by loading the overrides on the root of the virtual tree, we effectively
ensure that `npm ci` will throw an error when your package.json
overrides are not in sync with the tree in your package-lock.json
  • Loading branch information
nlf authored and lukekarrys committed Mar 28, 2022
1 parent bd96ae4 commit 99d8845
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions workspaces/arborist/lib/arborist/load-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = cls => class VirtualLoader extends cls {
async [loadRoot] (s) {
const pj = this.path + '/package.json'
const pkg = await rpj(pj).catch(() => s.data.packages['']) || {}
return this[loadWorkspaces](this[loadNode]('', pkg))
return this[loadWorkspaces](this[loadNode]('', pkg, true))
}

async [loadFromShrinkwrap] (s, root) {
Expand Down Expand Up @@ -264,7 +264,7 @@ module.exports = cls => class VirtualLoader extends cls {
}
}

[loadNode] (location, sw) {
[loadNode] (location, sw, loadOverrides) {
const p = this.virtualTree ? this.virtualTree.realpath : this.path
const path = resolve(p, location)
// shrinkwrap doesn't include package name unless necessary
Expand All @@ -290,6 +290,7 @@ module.exports = cls => class VirtualLoader extends cls {
optional,
devOptional,
peer,
loadOverrides,
})
// cast to boolean because they're undefined in the lock file when false
node.extraneous = !!sw.extraneous
Expand Down

0 comments on commit 99d8845

Please # to comment.