release: Make sure JSON ends with `\n`

pull/4792/head
Richard Hansen 2021-02-15 14:04:47 -05:00 committed by John McLear
parent ea4b2ef8fb
commit 565d020876
1 changed files with 5 additions and 1 deletions

View File

@ -26,7 +26,11 @@ if (!release) {
}
const readJson = (filename) => JSON.parse(fs.readFileSync(filename, {encoding: 'utf8', flag: 'r'}));
const writeJson = (filename, obj) => fs.writeFileSync(filename, JSON.stringify(obj, null, 2));
const writeJson = (filename, obj) => {
let json = JSON.stringify(obj, null, 2);
if (json !== '' && !json.endsWith('\n')) json += '\n';
fs.writeFileSync(filename, json);
};
const changelog = fs.readFileSync('CHANGELOG.md', {encoding: 'utf8', flag: 'r'});
const pkg = readJson('./src/package.json');