Skip to content

Commit

Permalink
fix: listing deps of a linked dep
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ruyadorno authored and nlf committed Sep 29, 2020
1 parent 2469ae5 commit 52114b7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ const ls = async (args) => {
!(node instanceof Arborist.Node) || (node[_depth] > depthToPrint)
return (shouldSkipChildren)
? []
: [...node.edgesOut.values()]
: [...(node.target || node).edgesOut.values()]
.filter(filterByEdgesTypes({
dev,
development,
Expand Down
1 change: 1 addition & 0 deletions tap-snapshots/test-lib-ls.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-loading-a-tree-containing-works
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list workspaces properly 1`] = `
filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-loading-a-tree-containing-workspaces
+-- a@1.0.0 -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/a
| \`-- c@1.0.0
\`-- b@1.0.0 -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/b
`
Expand Down
13 changes: 11 additions & 2 deletions test/lib/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -1396,12 +1396,21 @@ t.test('ls', (t) => {
}),
node_modules: {
a: t.fixture('symlink', '../a'),
b: t.fixture('symlink', '../b')
b: t.fixture('symlink', '../b'),
c: {
'package.json': JSON.stringify({
name: 'c',
version: '1.0.0'
})
}
},
a: {
'package.json': JSON.stringify({
name: 'a',
version: '1.0.0'
version: '1.0.0',
dependencies: {
c: '^1.0.0'
}
})
},
b: {
Expand Down

0 comments on commit 52114b7

Please sign in to comment.