diff --git a/lib/utils/explain-dep.js b/lib/utils/explain-dep.js index 096df97edfda3..ed69a02c143c0 100644 --- a/lib/utils/explain-dep.js +++ b/lib/utils/explain-dep.js @@ -64,7 +64,7 @@ const explainDependents = ({ name, dependents }, depth, color) => { const maxLen = 50 const showNames = [] for (let i = max; i < dependents.length; i++) { - const { from: { name } } = dependents[i] + const { from: { name = 'the root project' } } = dependents[i] len += name.length if (len >= maxLen && i < dependents.length - 1) { showNames.push('...') diff --git a/tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js b/tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js index 48f84e5111821..54a77bc122b4d 100644 --- a/tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js +++ b/tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js @@ -10,7 +10,7 @@ manydep@1.0.0 manydep@"1.0.0" from prod-dep@1.2.3 node_modules/prod-dep prod-dep@"1.x" from the root project - 6 more (optdep, extra-neos, deep-dev, peer, ...) + 7 more (optdep, extra-neos, deep-dev, peer, the root project, ...) ` exports[`test/lib/utils/explain-dep.js TAP > ellipses test two 1`] = ` @@ -18,7 +18,7 @@ manydep@1.0.0 manydep@"1.0.0" from prod-dep@1.2.3 node_modules/prod-dep prod-dep@"1.x" from the root project - 5 more (optdep, extra-neos, deep-dev, peer, a package with a pretty long name) + 6 more (optdep, extra-neos, deep-dev, peer, the root project, a package with a pretty long name) ` exports[`test/lib/utils/explain-dep.js TAP deepDev > explain color deep 1`] = ` @@ -90,6 +90,7 @@ exports[`test/lib/utils/explain-dep.js TAP manyDeps > explain color deep 1`] = ` peer manydep@">1.0.0-beta <1.0.1" from peer@1.0.0 peer node_modules/peer peer peer@"1.0.0" from the root project + manydep@">1.0.0-beta <1.0.1" from the root project manydep@"1" from a package with a pretty long name@1.2.3 manydep@"1" from another package with a pretty long name@1.2.3 manydep@"1" from yet another a package with a pretty long name@1.2.3 @@ -100,7 +101,7 @@ manydep@1.0.0 manydep@"1.0.0" from prod-dep@1.2.3 node_modules/prod-dep prod-dep@"1.x" from the root project - 7 more (optdep, extra-neos, deep-dev, peer, ...) + 8 more (optdep, extra-neos, deep-dev, peer, the root project, ...) ` exports[`test/lib/utils/explain-dep.js TAP manyDeps > print color 1`] = ` diff --git a/test/lib/utils/explain-dep.js b/test/lib/utils/explain-dep.js index ec450345f893f..9a205e3c39ce2 100644 --- a/test/lib/utils/explain-dep.js +++ b/test/lib/utils/explain-dep.js @@ -140,6 +140,14 @@ cases.manyDeps = { spec: '>1.0.0-beta <1.0.1', from: cases.peer, }, + { + type: 'prod', + name: 'manydep', + spec:'>1.0.0-beta <1.0.1', + from: { + location: '/path/to/project', + }, + }, { type: 'prod', name: 'manydep',