| 4 | const { cleanCwd } = require('../../fixtures/clean-snapshot') |
| 5 | |
| 6 | const 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 | |
| 30 | const mockHelp = async (t, { |
| 31 | man = { |