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:
authorkumavis <aaron@kumavis.me>2021-02-22 09:16:02 +0300
committerGar <gar+gh@danger.computer>2021-02-25 21:23:33 +0300
commit881a8558de5cb808c9efdcf3fb5d0a86a95e8eb0 (patch)
tree8ebce5fe9fb4528a35ad1d19d30867663abfe051 /lib/utils
parent28d036ae9179f742bd0518e558a54f014a7a895e (diff)
feat(explain): mark when dependency is bundled
When using `npm explain <package>` it's useful to see if the package has been bundled. This is especially useful when trying to understand the provenance of a package's content PR-URL: https://github.com/npm/cli/pull/2750 Credit: @kumavis Close: #2750 Reviewed-by: @nlf
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/explain-dep.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/utils/explain-dep.js b/lib/utils/explain-dep.js
index ed69a02c1..213493c65 100644
--- a/lib/utils/explain-dep.js
+++ b/lib/utils/explain-dep.js
@@ -6,6 +6,7 @@ const nocolor = {
yellow: s => s,
cyan: s => s,
magenta: s => s,
+ blue: s => s,
}
const explainNode = (node, depth, color) =>
@@ -13,11 +14,12 @@ const explainNode = (node, depth, color) =>
explainDependents(node, depth, color)
const colorType = (type, color) => {
- const { red, yellow, cyan, magenta } = color ? chalk : nocolor
+ const { red, yellow, cyan, magenta, blue } = color ? chalk : nocolor
const style = type === 'extraneous' ? red
: type === 'dev' ? yellow
: type === 'optional' ? cyan
: type === 'peer' ? magenta
+ : type === 'bundled' ? blue
: /* istanbul ignore next */ s => s
return style(type)
}
@@ -31,6 +33,7 @@ const printNode = (node, color) => {
dev,
optional,
peer,
+ bundled,
} = node
const { bold, dim } = color ? chalk : nocolor
const extra = []
@@ -46,6 +49,9 @@ const printNode = (node, color) => {
if (peer)
extra.push(' ' + bold(colorType('peer', color)))
+ if (bundled)
+ extra.push(' ' + bold(colorType('bundled', color)))
+
return `${bold(name)}@${bold(version)}${extra.join('')}` +
(location ? dim(`\n${location}`) : '')
}