blob: 809c05b33878b2051c46100dbc3831dd692e11e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
'use strict'
const { EOL } = require('os')
const computeMetadata = require('./deps.js').computeMetadata
const mutateIntoLogicalTree = require('./mutate-into-logical-tree.js')
var { getFundingInfo } = require('../utils/funding.js')
exports.getPrintFundingReport = getPrintFundingReport
exports.getPrintFundingReportJSON = getPrintFundingReportJSON
function getFundingResult ({ fund, idealTree }) {
if (fund) {
const fundingInfoTree =
mutateIntoLogicalTree.asReadInstalled(
computeMetadata(idealTree)
)
const fundResult = getFundingInfo(fundingInfoTree, { countOnly: true })
return fundResult
} else {
return {}
}
}
function getPrintFundingReport ({ fund, idealTree }, opts) {
const fundResult = getFundingResult({ fund, idealTree })
const { length } = fundResult || {}
const { json } = opts || {}
function padding (msg) {
return json ? '' : (EOL + msg)
}
function packageQuantity (amount) {
return `package${amount > 1 ? 's are' : ' is'}`
}
if (!length) return ''
return padding('') + length + ' ' +
packageQuantity(length) +
' looking for funding' +
padding(' run `npm fund` for details\n')
}
function getPrintFundingReportJSON ({ fund, idealTree }) {
return getPrintFundingReport({ fund, idealTree }, { json: true })
}
|