fix(usage-to-readme): fix multiple .USAGE.md changes

This commit is contained in:
Julien Fontanet
2024-01-19 10:23:52 +01:00
parent 3892efcca2
commit a624330818
+7 -1
View File
@@ -10,12 +10,15 @@ const { execFile } = require('node:child_process')
const generateReadme = readFile(join(__dirname, 'README.md.tpl'), 'utf8').then(compile) const generateReadme = readFile(join(__dirname, 'README.md.tpl'), 'utf8').then(compile)
async function usageToReadme(...args) { async function usageToReadme(...args) {
console.error(process.argv, args)
const gitAdd = args[0] === '--git-add' const gitAdd = args[0] === '--git-add'
if (gitAdd) { if (gitAdd) {
args.shift() args.shift()
} }
const usagePath = args[0] for (const usagePath of args) {
console.error(usagePath)
const dir = dirname(usagePath) const dir = dirname(usagePath)
const [usage, pkg] = await Promise.all([ const [usage, pkg] = await Promise.all([
@@ -33,11 +36,14 @@ async function usageToReadme(...args) {
.on('exit', code => { .on('exit', code => {
if (code !== 0) { if (code !== 0) {
reject(new Error('command exited with non-zero status code: ' + code)) reject(new Error('command exited with non-zero status code: ' + code))
} else {
resolve()
} }
}) })
}) })
} }
} }
}
if (module.parent !== null) { if (module.parent !== null) {
module.exports = usageToReadme module.exports = usageToReadme