Skip to content

Commit

Permalink
explain-dep: handle shortening edge from root project
Browse files Browse the repository at this point in the history
Fixes: #2134
  • Loading branch information
isaacs committed Nov 11, 2020
1 parent 5ae21e4 commit cb3d489
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('...')
Expand Down
7 changes: 4 additions & 3 deletions tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ [email protected]
manydep@"1.0.0" from [email protected]
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`] = `
[email protected]
manydep@"1.0.0" from [email protected]
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`] = `
Expand Down Expand Up @@ -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
Expand All @@ -100,7 +101,7 @@ [email protected]
manydep@"1.0.0" from [email protected]
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`] = `
Expand Down
8 changes: 8 additions & 0 deletions test/lib/utils/explain-dep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit cb3d489

Please sign in to comment.