Fix compose-changelog.js overwriting itself when called with no arguments

This commit is contained in:
Silvano Cerza 2022-01-27 18:24:57 +01:00 committed by Silvano Cerza
parent 8a0454db51
commit b3b22795f8

View File

@ -27,7 +27,12 @@
return acc + `# ${item.name}\n\n${body}\n\n---\n\n`;
}, '');
const changelogFile = path.resolve(process.argv[process.argv.length - 1]);
const args = process.argv.slice(2)
if (args.length == 0) {
console.error("Missing argument to destination file")
process.exit(1)
}
const changelogFile = path.resolve(args[0]);
await fs.writeFile(
changelogFile,