MCPcopy Index your code
hub / github.com/nodejs/node / exec

Method exec

deps/npm/lib/commands/fund.js:42–90  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

40 }
41
42 async exec (args) {
43 const spec = args[0]
44
45 let fundingSourceNumber = this.npm.config.get('which')
46 if (fundingSourceNumber != null) {
47 fundingSourceNumber = parseInt(fundingSourceNumber, 10)
48 if (isNaN(fundingSourceNumber) || fundingSourceNumber < 1) {
49 throw errCode(
50 `${this.usageMessage({ which: 'fundingSourceNumber' })} must be given a positive integer`,
51 'EFUNDNUMBER'
52 )
53 }
54 }
55
56 if (this.npm.global) {
57 throw errCode(
58 `${this.usageMessage()} does not support global packages`,
59 'EFUNDGLOBAL'
60 )
61 }
62
63 const where = this.npm.prefix
64 const Arborist = require('@npmcli/arborist')
65 const arb = new Arborist({ ...this.npm.flatOptions, path: where })
66 const tree = await arb.loadActual()
67
68 if (spec) {
69 await this.openFundingUrl({
70 path: where,
71 tree,
72 spec,
73 fundingSourceNumber,
74 })
75 return
76 }
77
78 // TODO: add !workspacesEnabled option handling to libnpmfund
79 const fundingInfo = getFundingInfo(tree, {
80 ...this.flatOptions,
81 Arborist,
82 workspaces: this.workspaceNames,
83 })
84
85 if (this.npm.config.get('json')) {
86 output.buffer(fundingInfo)
87 } else {
88 output.standard(this.printHuman(fundingInfo))
89 }
90 }
91
92 printHuman (fundingInfo) {
93 const unicode = this.npm.config.get('unicode')

Callers

nothing calls this directly

Calls 7

usageMessageMethod · 0.95
openFundingUrlMethod · 0.95
printHumanMethod · 0.95
errCodeFunction · 0.85
getMethod · 0.65
requireFunction · 0.50
bufferMethod · 0.45

Tested by

no test coverage detected