Skip to content

Commit d1e8b3a

Browse files
rodion-arrmhdawson
authored andcommitted
Fix endless loop in case circular dependency occurred in packages
1 parent f5cfe87 commit d1e8b3a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/cli/commands/show.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22
const support = require('../../../index.js');
33
const Arborist = require('@npmcli/arborist');
4+
const printed = {};
45

56
// print out the information for a module and its
67
// children
@@ -22,6 +23,12 @@ async function printModule (module, depth, argv) {
2223
console.log(`${' '.repeat(2 * (depth + 1))}${moduleInfo} - ${supportInfo.url}`);
2324
}
2425

26+
// avoid printing children of already printed module in current branch
27+
if (pkg.name in printed && depth > printed[pkg.name]) {
28+
return;
29+
}
30+
printed[pkg.name] = depth;
31+
2532
// sort child modules
2633
module.edgesOut = new Map([...module.edgesOut.entries()].sort());
2734

0 commit comments

Comments
 (0)