Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-08-16 20:07:55 +0300
committerNathan Fritz <fritzy@github.com>2022-08-17 03:54:17 +0300
commitcd2b1e6f5fbd85691465bbfe275c8baf1b6e2746 (patch)
tree933159adaa35416580970c2aecd2c4c8006b0675 /lib/utils
parent05d9bcf7e557e0dbecbd80d4d1be332963761e69 (diff)
fix(explain): display override information
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/explain-dep.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/utils/explain-dep.js b/lib/utils/explain-dep.js
index 107f68549..cd53a2269 100644
--- a/lib/utils/explain-dep.js
+++ b/lib/utils/explain-dep.js
@@ -8,6 +8,7 @@ const nocolor = {
magenta: s => s,
blue: s => s,
green: s => s,
+ gray: s => s,
}
const { relative } = require('path')
@@ -18,13 +19,14 @@ const explainNode = (node, depth, color) =>
explainLinksIn(node, depth, color)
const colorType = (type, color) => {
- const { red, yellow, cyan, magenta, blue, green } = color ? chalk : nocolor
+ const { red, yellow, cyan, magenta, blue, green, gray } = color ? chalk : nocolor
const style = type === 'extraneous' ? red
: type === 'dev' ? yellow
: type === 'optional' ? cyan
: type === 'peer' ? magenta
: type === 'bundled' ? blue
: type === 'workspace' ? green
+ : type === 'overridden' ? gray
: /* istanbul ignore next */ s => s
return style(type)
}
@@ -40,6 +42,7 @@ const printNode = (node, color) => {
peer,
bundled,
isWorkspace,
+ overridden,
} = node
const { bold, dim, green } = color ? chalk : nocolor
const extra = []
@@ -63,6 +66,10 @@ const printNode = (node, color) => {
extra.push(' ' + bold(colorType('bundled', color)))
}
+ if (overridden) {
+ extra.push(' ' + bold(colorType('overridden', color)))
+ }
+
const pkgid = isWorkspace
? green(`${name}@${version}`)
: `${bold(name)}@${bold(version)}`
@@ -112,11 +119,15 @@ const explainDependents = ({ name, dependents }, depth, color) => {
return str.split('\n').join('\n ')
}
-const explainEdge = ({ name, type, bundled, from, spec }, depth, color) => {
+const explainEdge = ({ name, type, bundled, from, spec, rawSpec, overridden }, depth, color) => {
const { bold } = color ? chalk : nocolor
- const dep = type === 'workspace'
+ let dep = type === 'workspace'
? bold(relative(from.location, spec.slice('file:'.length)))
: `${bold(name)}@"${bold(spec)}"`
+ if (overridden) {
+ dep = `${colorType('overridden', color)} ${dep} (was "${rawSpec}")`
+ }
+
const fromMsg = ` from ${explainFrom(from, depth, color)}`
return (type === 'prod' ? '' : `${colorType(type, color)} `) +