Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: npm help json/global command on windows #7496

Merged
merged 2 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions docs/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,45 @@ const run = async ({ content, template, nav, man, html, md }) => {
: []),
])

const aliases = [
fullName === 'configuring-npm/package-json' && 'configuring-npm/npm-json',
fullName === 'configuring-npm/folders' && 'configuring-npm/npm-global',
].filter(Boolean)

if (data.section) {
const manSrc = applyTransforms(transformedSrc, [
const manSource = applyTransforms(transformedSrc, [
transform.helpLinks,
transform.man,
])
const manPaths = [
name,
fullName === 'configuring-npm/package-json' && 'npm-json',
fullName === 'configuring-npm/folders' && 'npm-global',
].filter(Boolean).map(p => applyTransforms(p, [transform.manPath]))

acc.man.push(...manPaths.map((manPath) => ({
path: manPath,
fullPath: join(man, manPath),
src: manSrc,
})))
// Man page aliases are only the basename since the man pages have no hierarchy
acc.man.push(...[name, ...aliases.map(a => basename(a))]
.map((p) => applyTransforms(p, [transform.manPath]))
.map((manPath) => ({
path: manPath,
fullPath: join(man, manPath),
src: manSource,
}))
)
}

acc.html.push({
path: `${fullName}.html`,
fullPath: join(html, `${fullName}.html`),
src: applyTransforms(transformedSrc, [transform.html]),
})

// html docs are used for npm help on Windows
const htmlSource = applyTransforms(transformedSrc, [transform.html])
acc.html.push(...[fullName, ...aliases].map((htmlPath) => ({
path: `${htmlPath}.html`,
fullPath: join(html, `${htmlPath}.html`),
src: htmlSource,
})))

// Markdown pages don't get aliases here. These are used to build the website so any redirects
// for these pages are applied in npm/documentation. Not ideal but there are also many more
// redirects that we would never apply to man or html docs pages
const mdSource = applyTransforms(transformedSrc, [transform.md])
acc.md.push({
path: childPath,
fullPath: join(md, childPath),
src: applyTransforms(transformedSrc, [transform.md]),
src: mdSource,
})

return acc
}, { man: [], html: [], md: [] })

Expand Down
Loading