Skip to content

Commit

Permalink
doc: fix hyperlink refs in man page docs
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Nov 5, 2019
1 parent cc36fca commit 8287bf6
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions scripts/docs-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,17 @@ var dest = args[1] || src
fs.readFile(src, 'utf8', function (err, data) {
if (err) return console.log(err)

var fileExt = src.split('.').pop()
var result = data.replace(/@VERSION@/g, npm.version)
.replace(/---([\s\S]+)---/g, '')
.replace(/(npm-)?([a-zA-Z\\.-]*)\(1\)/g, 'npm help $2')
.replace(/(npm-)?([a-zA-Z\\.-]*)\((5|7)\)/g, 'npm help $2')
.replace(/npm(1)/g, 'npm help npm')
.replace(/\[([^\]]+)\]\(\/cli-commands\/([^\)]+)\)/g, 'npm help $2')
.replace(/\[([^\]]+)\]\(\/configuring-npm\/([^\)]+)\)/g, 'npm help $2')
.replace(/\[([^\]]+)\]\(\/using-npm\/([^\)]+)\)/g, 'npm help $2')
.trim()

if (fileExt === 'md') {
result = marked(
result.replace(/---([\s\S]+)---/g, '')
.replace(/(npm-)?([a-zA-Z\\.-]*)\(1\)/g, 'npm help $2')
.replace(/(npm-)?([a-zA-Z\\.-]*)\((5|7)\)/g, 'npm help $2')
.replace(/(npm-)?([a-zA-Z\\.-]*)\(3\)/g, 'npm apihelp $2')
.replace(/npm(1)/g, 'npm help npm')
.replace(/npm(3)/g, 'npm apihelp npm')
.trim()
)
}

fs.writeFile(dest, result, 'utf8', function (err) {
fs.writeFile(dest, marked(result), 'utf8', function (err) {
if (err) return console.log(err)
})
})

0 comments on commit 8287bf6

Please sign in to comment.