From 6ef53ee73a2a0ed26f8c1507018d201a7bd36d1e Mon Sep 17 00:00:00 2001 From: Ruy Adorno Date: Tue, 28 Jul 2020 20:18:20 -0400 Subject: fix: npm ls duplicated items When having nodes that are children of extraneous nodes, items were getting printed twice using `npm ls`. This fixes it by keeping track of seen nodes while iterating in a same children level and effectively avoiding printing a same item twice. fix: #1573 PR-URL: https://github.com/npm/cli/pull/1576 Credit: @ruyadorno Close: #1576 Reviewed-by: @isaacs --- tap-snapshots/test-lib-ls.js-TAP.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tap-snapshots') diff --git a/tap-snapshots/test-lib-ls.js-TAP.test.js b/tap-snapshots/test-lib-ls.js-TAP.test.js index 1363eec70..6f0c0beff 100644 --- a/tap-snapshots/test-lib-ls.js-TAP.test.js +++ b/tap-snapshots/test-lib-ls.js-TAP.test.js @@ -373,6 +373,16 @@ test-npm-ls@1.0.0 {CWD}/ls-ls-extraneous-deps ` +exports[`test/lib/ls.js TAP ls filtering by child of missing dep > should print tree and not duplicate child of missing items 1`] = ` +filter-by-child-of-missing-dep@1.0.0 {CWD}/ls-ls-filtering-by-child-of-missing-dep ++-- b@1.0.0 extraneous +| \`-- c@1.0.0 deduped ++-- c@1.0.0 extraneous +\`-- d@1.0.0 extraneous + \`-- c@2.0.0 extraneous + +` + exports[`test/lib/ls.js TAP ls from and resolved properties > should not be printed in tree output 1`] = ` test-npm-ls@1.0.0 {CWD}/ls-ls-from-and-resolved-properties \`-- simple-output@2.1.1 -- cgit v1.2.3