MCPcopy Create free account
hub / github.com/npm/cli / cmdUsages

Function cmdUsages

lib/utils/npm-usage.js:60–74  ·  view source on GitHub ↗
(Npm)

Source from the content-addressed store, hash-verified

58}
59
60const cmdUsages = (Npm) => {
61 // return a string of <command>: <usage>
62 let maxLen = 0
63 const set = []
64 for (const c of commands) {
65 set.push([c, Npm.cmd(c).getUsage(null, false).split('\n')])
66 maxLen = Math.max(maxLen, c.length)
67 }
68
69 return set.map(([name, usageLines]) => {
70 const gutter = indent(maxLen - name.length + 1)
71 const usage = usageLines.join(indentNewline(INDENT + maxLen + 1))
72 return indentNewline() + name + gutter + usage
73 }).join('\n')
74}

Callers 1

npm-usage.jsFile · 0.85

Calls 5

indentFunction · 0.85
indentNewlineFunction · 0.85
pushMethod · 0.80
getUsageMethod · 0.80
cmdMethod · 0.80

Tested by

no test coverage detected