Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions workspaces/arborist/lib/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ class Edge {
return false
}

// If there's no override we just use the spec.
if (!this.overrides?.keySpec) {
return depValid(node, this.spec, this.#accept, this.#from)
}

// NOTE: this condition means we explicitly do not support overriding
// bundled dependencies
if (node.inDepBundle) {
return depValid(node, this.rawSpec, this.#accept, this.#from)
}

// If there's no override we just use the spec.
if (!this.overrides?.keySpec) {
return depValid(node, this.spec, this.#accept, this.#from)
}
// There's some override. If the target node satisfies the overriding spec
// then it's okay.
if (depValid(node, this.spec, this.#accept, this.#from)) {
Expand Down
26 changes: 26 additions & 0 deletions workspaces/arborist/test/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,32 @@ t.test('edge with overrides should not crash when target has no overrides', t =>
t.end()
})

t.test('satisfiedBy does not check bundling without an applicable override', t => {
const Node = require('../lib/node.js')
for (const overrides of [undefined, new OverrideSet({ overrides: { other: '2.x' } })]) {
const from = new Node({
path: '/root',
pkg: { name: 'root', dependencies: { child: '1.x' } },
})
const edge = from.edgesOut.get('child')
edge.overrides = overrides
for (const version of ['1.0.0', '2.0.0']) {
const candidate = new Node({
path: '/child',
pkg: { name: 'child', version },
})
Object.defineProperty(candidate, 'inDepBundle', {
get: () => {
t.fail('bundling cannot affect an edge without an applicable override')
return false
},
})
t.equal(edge.satisfiedBy(candidate), version === '1.0.0')
}
}
t.end()
})

t.test('overrides and bundled deps in satisfiedBy', t => {
const makeNode = (name, version, extras = {}) => ({
name,
Expand Down
Loading