Skip to content

Commit 0e7511d

Browse files
fritzysalvadorj
andauthored
fix(arborist): _findMissingEdges missing dependency due to inconsistent path separators (#4261)
Co-authored-by: Salvador Jacobi <[email protected]>
1 parent f66290e commit 0e7511d

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

workspaces/arborist/lib/arborist/load-actual.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ module.exports = cls => class ActualLoader extends cls {
435435
if (d.dummy) {
436436
// it's a placeholder, so likely would not have loaded this dep,
437437
// unless another dep in the tree also needs it.
438-
const depPath = `${p}/node_modules/${name}`
438+
const depPath = normalize(`${p}/node_modules/${name}`)
439439
const cached = this[_cache].get(depPath)
440440
if (!cached || cached.dummy) {
441441
depPromises.push(this[_loadFSNode]({

workspaces/arborist/test/arborist/load-actual.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,51 @@ t.test('load global space with link deps', async t => {
423423
})
424424
})
425425

426+
t.test('no edge errors for nested deps', async t => {
427+
const path = t.testdir({
428+
'package.json': JSON.stringify({
429+
name: 'a',
430+
version: '1.0.0',
431+
dependencies: {
432+
b: '1.0.0',
433+
},
434+
}),
435+
node_modules: {
436+
b: {
437+
'package.json': JSON.stringify({
438+
name: 'b',
439+
version: '1.0.0',
440+
dependencies: {
441+
c: '1.0.0',
442+
},
443+
}),
444+
},
445+
c: {
446+
'package.json': JSON.stringify({
447+
name: 'c',
448+
version: '1.0.0',
449+
}),
450+
},
451+
},
452+
})
453+
454+
// disable treeCheck since it prevents the original issue from occuring
455+
const ArboristNoTreeCheck = t.mock('../../lib/arborist', {
456+
'../../lib/tree-check.js': tree => tree,
457+
})
458+
const loadActualNoTreeCheck = (path, opts) =>
459+
new ArboristNoTreeCheck({ path, ...opts }).loadActual(opts)
460+
461+
const tree = await loadActualNoTreeCheck(path)
462+
463+
// assert that no outgoing edges have errors
464+
for (const node of tree.inventory.values()) {
465+
for (const [name, edge] of node.edgesOut.entries()) {
466+
t.equal(edge.error, null, `node ${node.name} has outgoing edge to ${name} with error ${edge.error}`)
467+
}
468+
}
469+
})
470+
426471
t.test('loading a workspace maintains overrides', async t => {
427472
const path = t.testdir({
428473
'package.json': JSON.stringify({

0 commit comments

Comments
 (0)