@@ -8,6 +8,7 @@ const nocolor = {
88 magenta : s => s ,
99 blue : s => s ,
1010 green : s => s ,
11+ gray : s => s ,
1112}
1213
1314const { relative } = require ( 'path' )
@@ -18,13 +19,14 @@ const explainNode = (node, depth, color) =>
1819 explainLinksIn ( node , depth , color )
1920
2021const colorType = ( type , color ) => {
21- const { red, yellow, cyan, magenta, blue, green } = color ? chalk : nocolor
22+ const { red, yellow, cyan, magenta, blue, green, gray } = color ? chalk : nocolor
2223 const style = type === 'extraneous' ? red
2324 : type === 'dev' ? yellow
2425 : type === 'optional' ? cyan
2526 : type === 'peer' ? magenta
2627 : type === 'bundled' ? blue
2728 : type === 'workspace' ? green
29+ : type === 'overridden' ? gray
2830 : /* istanbul ignore next */ s => s
2931 return style ( type )
3032}
@@ -40,6 +42,7 @@ const printNode = (node, color) => {
4042 peer,
4143 bundled,
4244 isWorkspace,
45+ overridden,
4346 } = node
4447 const { bold, dim, green } = color ? chalk : nocolor
4548 const extra = [ ]
@@ -63,6 +66,10 @@ const printNode = (node, color) => {
6366 extra . push ( ' ' + bold ( colorType ( 'bundled' , color ) ) )
6467 }
6568
69+ if ( overridden ) {
70+ extra . push ( ' ' + bold ( colorType ( 'overridden' , color ) ) )
71+ }
72+
6673 const pkgid = isWorkspace
6774 ? green ( `${ name } @${ version } ` )
6875 : `${ bold ( name ) } @${ bold ( version ) } `
@@ -112,11 +119,15 @@ const explainDependents = ({ name, dependents }, depth, color) => {
112119 return str . split ( '\n' ) . join ( '\n ' )
113120}
114121
115- const explainEdge = ( { name, type, bundled, from, spec } , depth , color ) => {
122+ const explainEdge = ( { name, type, bundled, from, spec, rawSpec , overridden } , depth , color ) => {
116123 const { bold } = color ? chalk : nocolor
117- const dep = type === 'workspace'
124+ let dep = type === 'workspace'
118125 ? bold ( relative ( from . location , spec . slice ( 'file:' . length ) ) )
119126 : `${ bold ( name ) } @"${ bold ( spec ) } "`
127+ if ( overridden ) {
128+ dep = `${ colorType ( 'overridden' , color ) } ${ dep } (was "${ rawSpec } ")`
129+ }
130+
120131 const fromMsg = ` from ${ explainFrom ( from , depth , color ) } `
121132
122133 return ( type === 'prod' ? '' : `${ colorType ( type , color ) } ` ) +
0 commit comments