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:
Diffstat (limited to 'lib/fund.js')
-rw-r--r--lib/fund.js37
1 files changed, 22 insertions, 15 deletions
diff --git a/lib/fund.js b/lib/fund.js
index fde01f469..d1c58d9b9 100644
--- a/lib/fund.js
+++ b/lib/fund.js
@@ -42,26 +42,33 @@ function printHuman (fundingInfo, { color, unicode }) {
const result = depth({
tree: fundingInfo,
+
+ // composes human readable package name
+ // and creates a new archy item for readable output
visit: ({ name, version, funding }) => {
- // composes human readable package name
- // and creates a new archy item for readable output
- const { url } = funding || {}
+ const [fundingSource] = []
+ .concat(normalizeFunding(funding))
+ .filter(isValidFunding)
+ const { url } = fundingSource || {}
const pkgRef = getPrintableName({ name, version })
- const label = url ? tree({
- label: color ? chalk.bgBlack.white(url) : url,
- nodes: [pkgRef]
- }).trim() : pkgRef
let item = {
- label
+ label: pkgRef
}
- // stacks all packages together under the same item
- if (seenUrls.has(url)) {
- item = seenUrls.get(url)
- item.label += `, ${pkgRef}`
- return null
- } else {
- seenUrls.set(url, item)
+ if (url) {
+ item.label = tree({
+ label: color ? chalk.bgBlack.white(url) : url,
+ nodes: [pkgRef]
+ }).trim()
+
+ // stacks all packages together under the same item
+ if (seenUrls.has(url)) {
+ item = seenUrls.get(url)
+ item.label += `, ${pkgRef}`
+ return null
+ } else {
+ seenUrls.set(url, item)
+ }
}
return item