From 3e7f53909cf35f2521572d6c43f32f0c7300654c Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Mon, 28 Sep 2020 14:50:15 -0400 Subject: [PATCH] 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. --- lib/ls.js | 2 +- tap-snapshots/test-lib-ls.js-TAP.test.js | 1 + test/lib/ls.js | 13 +++++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/ls.js b/lib/ls.js index 09e70c9be8ef4..7d9be02fb6b37 100644 --- a/lib/ls.js +++ b/lib/ls.js @@ -423,7 +423,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, diff --git a/tap-snapshots/test-lib-ls.js-TAP.test.js b/tap-snapshots/test-lib-ls.js-TAP.test.js index b5659a62e2868..8245a942fdc8a 100644 --- a/tap-snapshots/test-lib-ls.js-TAP.test.js +++ b/tap-snapshots/test-lib-ls.js-TAP.test.js @@ -433,6 +433,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 ` diff --git a/test/lib/ls.js b/test/lib/ls.js index cdf5cc9f6ed29..ac4b8d390f19d 100644 --- a/test/lib/ls.js +++ b/test/lib/ls.js @@ -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: {