Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(arborist) _findMissingEdges missing dependency due to inconsistent path separators #4261

Merged
merged 3 commits into from Mar 15, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/arborist/load-actual.js
Expand Up @@ -435,7 +435,7 @@ module.exports = cls => class ActualLoader extends cls {
if (d.dummy) {
// it's a placeholder, so likely would not have loaded this dep,
// unless another dep in the tree also needs it.
const depPath = `${p}/node_modules/${name}`
const depPath = normalize(`${p}/node_modules/${name}`)
const cached = this[_cache].get(depPath)
if (!cached || cached.dummy) {
depPromises.push(this[_loadFSNode]({
Expand Down
45 changes: 45 additions & 0 deletions workspaces/arborist/test/arborist/load-actual.js
Expand Up @@ -423,6 +423,51 @@ t.test('load global space with link deps', async t => {
})
})

t.test('no edge errors for nested deps', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
name: 'a',
version: '1.0.0',
dependencies: {
b: '1.0.0',
},
}),
node_modules: {
b: {
'package.json': JSON.stringify({
name: 'b',
version: '1.0.0',
dependencies: {
c: '1.0.0',
},
}),
},
c: {
'package.json': JSON.stringify({
name: 'c',
version: '1.0.0',
}),
},
},
})

// disable treeCheck since it prevents the original issue from occuring
const ArboristNoTreeCheck = t.mock('../../lib/arborist', {
'../../lib/tree-check.js': tree => tree,
})
const loadActualNoTreeCheck = (path, opts) =>
new ArboristNoTreeCheck({ path, ...opts }).loadActual(opts)

const tree = await loadActualNoTreeCheck(path)

// assert that no outgoing edges have errors
for (const node of tree.inventory.values()) {
for (const [name, edge] of node.edgesOut.entries()) {
t.equal(edge.error, null, `node ${node.name} has outgoing edge to ${name} with error ${edge.error}`)
}
}
})

t.test('loading a workspace maintains overrides', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
Expand Down