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

Function genManPages

test/lib/commands/help.js:6–28  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

4const { cleanCwd } = require('../../fixtures/clean-snapshot')
5
6const genManPages = (obj) => {
7 const man = {}
8 const resPages = new Set()
9
10 for (const [section, pages] of Object.entries(obj)) {
11 const num = parseInt(section, 10)
12 man[`man${num}`] = {}
13
14 const sectionPages = []
15 for (const name of pages) {
16 man[`man${num}`][`${name}.${section}`] = `.TH "${name.toUpperCase()}" "${num}"`
17 sectionPages.push(name.replace(/^npm-/, ''))
18 }
19
20 // return a sorted list of uniq pages in order to test completion
21 for (const p of sectionPages.sort(localeCompare)) {
22 resPages.add(p)
23 }
24 }
25
26 // man directory name is hardcoded in the command
27 return { fixtures: { man }, pages: [...resPages.values()] }
28}
29
30const mockHelp = async (t, {
31 man = {

Callers 1

mockHelpFunction · 0.85

Calls 3

pushMethod · 0.80
replaceMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected