Skip to content

Commit 798a6e3

Browse files
ruyadornonlf
authored andcommitted
fix: listing deps of a linked dep
npm ls was failing to properly follow symlink targets in order to find its dependencies to get printed output. PR-URL: #1871 Credit: @ruyadorno Close: #1871 Reviewed-by: @nlf
1 parent ee79c55 commit 798a6e3

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/ls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ const ls = async (args) => {
428428
!(node instanceof Arborist.Node) || (node[_depth] > depthToPrint)
429429
return (shouldSkipChildren)
430430
? []
431-
: [...node.edgesOut.values()]
431+
: [...(node.target || node).edgesOut.values()]
432432
.filter(filterByEdgesTypes({
433433
dev,
434434
development,

tap-snapshots/test-lib-ls.js-TAP.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-loading-a-tree-containing-works
453453
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list workspaces properly 1`] = `
454454
filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-loading-a-tree-containing-workspaces
455455
+-- a@1.0.0 -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/a
456+
| \`-- c@1.0.0
456457
\`-- b@1.0.0 -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/b
457458
458459
`

test/lib/ls.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,12 +1396,21 @@ t.test('ls', (t) => {
13961396
}),
13971397
node_modules: {
13981398
a: t.fixture('symlink', '../a'),
1399-
b: t.fixture('symlink', '../b')
1399+
b: t.fixture('symlink', '../b'),
1400+
c: {
1401+
'package.json': JSON.stringify({
1402+
name: 'c',
1403+
version: '1.0.0'
1404+
})
1405+
}
14001406
},
14011407
a: {
14021408
'package.json': JSON.stringify({
14031409
name: 'a',
1404-
version: '1.0.0'
1410+
version: '1.0.0',
1411+
dependencies: {
1412+
c: '^1.0.0'
1413+
}
14051414
})
14061415
},
14071416
b: {

0 commit comments

Comments
 (0)