From 565d0208766b460d6340ba3bd38cbe78f09c677e Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 15 Feb 2021 14:04:47 -0500 Subject: [PATCH] release: Make sure JSON ends with `\n` --- src/bin/release.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bin/release.js b/src/bin/release.js index 144a078cd..9f0b251ec 100644 --- a/src/bin/release.js +++ b/src/bin/release.js @@ -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');