"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "scripts/docs-build.js" between
npm-cli-7.16.0.tar.gz and npm-cli-7.17.0.tar.gz

About: npm is a JavaScript package manager (requires node v6 or higher).

docs-build.js  (npm-cli-7.16.0):docs-build.js  (npm-cli-7.17.0)
#!/usr/bin/env node #!/usr/bin/env node
var fs = require('fs') var fs = require('fs')
var marked = require('marked-man') var marked = require('marked-man')
var npm = require('../lib/npm.js') var npm = require('../lib/npm.js')
var args = process.argv.slice(2) var args = process.argv.slice(2)
var src = args[0] var src = args[0]
var dest = args[1] || src var dest = args[1] || src
fs.readFile(src, 'utf8', function (err, data) { fs.readFile(src, 'utf8', function (err, data) {
if (err) return console.log(err) if (err)
return console.log(err)
function frontmatter (match, p1) { function frontmatter (match, p1) {
const fm = { } const fm = { }
p1.split(/\r?\n/).forEach((kv) => { p1.split(/\r?\n/).forEach((kv) => {
let result = kv.match(/^([^\s:]+):\s*(.*)/) const result = kv.match(/^([^\s:]+):\s*(.*)/)
if (result) { if (result)
fm[result[1]] = result[2] fm[result[1]] = result[2]
}
}) })
return `# ${fm['title']}(${fm['section']}) - ${fm['description']}` return `# ${fm.title}(${fm.section}) - ${fm.description}`
} }
function replacer (match, p1) { function replacer (match, p1) {
return 'npm help ' + p1.replace(/npm /, '') return 'npm help ' + p1.replace(/npm /, '')
} }
var result = data.replace(/@VERSION@/g, npm.version) var result = data.replace(/@VERSION@/g, npm.version)
.replace(/^---\n([\s\S]+\n)---/, frontmatter) .replace(/^---\n([\s\S]+\n)---/, frontmatter)
.replace(/\[([^\]]+)\]\(\/commands\/([^)]+)\)/g, replacer) .replace(/\[([^\]]+)\]\(\/commands\/([^)]+)\)/g, replacer)
.replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, replacer) .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, replacer)
.replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, replacer) .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, replacer)
.trim() .trim()
fs.writeFile(dest, marked(result), 'utf8', function (err) { fs.writeFile(dest, marked(result), 'utf8', function (err) {
if (err) return console.log(err) if (err)
return console.log(err)
}) })
}) })
 End of changes. 5 change blocks. 
6 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)