From 6700bfae560cc43234a57239ea7de678223d98c5 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 5 Nov 2019 10:22:35 -0800 Subject: [PATCH] doc: fix hyperlink refs in man page docs PR-URL: https://github.com/npm/cli/pull/283 Credit: @isaacs Close: #283 Reviewed-by: @ruyadorno --- scripts/docs-build.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/docs-build.js b/scripts/docs-build.js index fd7d74f642a0a..f6b87ae9d0445 100644 --- a/scripts/docs-build.js +++ b/scripts/docs-build.js @@ -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) }) })