diff --git a/scripts/docs-build.js b/scripts/docs-build.js index fd7d74f642a0a..d07d4e29dd388 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) }) })