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
diff options
context:
space:
mode:
-rw-r--r--lib/explain.js3
-rw-r--r--lib/utils/explain-dep.js8
-rw-r--r--tap-snapshots/test-lib-utils-explain-dep.js-TAP.test.js22
-rw-r--r--test/lib/utils/explain-dep.js17
4 files changed, 48 insertions, 2 deletions
diff --git a/lib/explain.js b/lib/explain.js
index 9176f2e6c..a0a4427bc 100644
--- a/lib/explain.js
+++ b/lib/explain.js
@@ -30,7 +30,7 @@ const explain = async (args) => {
const expls = []
for (const node of nodes) {
- const { extraneous, dev, optional, devOptional, peer } = node
+ const { extraneous, dev, optional, devOptional, peer, inBundle } = node
const expl = node.explain()
if (extraneous)
expl.extraneous = true
@@ -39,6 +39,7 @@ const explain = async (args) => {
expl.optional = optional
expl.devOptional = devOptional
expl.peer = peer
+ expl.bundled = inBundle
}
expls.push(expl)
}
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}`) : '')
}
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 54a77bc12..6d169bca6 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
@@ -21,6 +21,28 @@ manydep@1.0.0
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 bundled > explain color deep 1`] = `
+bundle-of-joy@1.0.0 bundled
+node_modules/bundle-of-joy
+ prod-dep@"1.x" from the root project
+`
+
+exports[`test/lib/utils/explain-dep.js TAP bundled > explain nocolor shallow 1`] = `
+bundle-of-joy@1.0.0 bundled
+node_modules/bundle-of-joy
+ prod-dep@"1.x" from the root project
+`
+
+exports[`test/lib/utils/explain-dep.js TAP bundled > print color 1`] = `
+bundle-of-joy@1.0.0 bundled
+node_modules/bundle-of-joy
+`
+
+exports[`test/lib/utils/explain-dep.js TAP bundled > print nocolor 1`] = `
+bundle-of-joy@1.0.0 bundled
+node_modules/bundle-of-joy
+`
+
exports[`test/lib/utils/explain-dep.js TAP deepDev > explain color deep 1`] = `
deep-dev@2.3.4 dev
node_modules/deep-dev
diff --git a/test/lib/utils/explain-dep.js b/test/lib/utils/explain-dep.js
index 28f14477a..1b8c4ae38 100644
--- a/test/lib/utils/explain-dep.js
+++ b/test/lib/utils/explain-dep.js
@@ -97,6 +97,23 @@ const cases = {
],
},
+ bundled: {
+ name: 'bundle-of-joy',
+ version: '1.0.0',
+ location: 'node_modules/bundle-of-joy',
+ bundled: true,
+ dependents: [
+ {
+ type: 'prod',
+ name: 'prod-dep',
+ spec: '1.x',
+ from: {
+ location: '/path/to/project',
+ },
+ },
+ ],
+ },
+
extraneous: {
name: 'extra-neos',
version: '1337.420.69-lol',