From bba47ea2df80721f2f6faf3f9ed16d6a16155de2 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 9 Jan 2021 18:28:11 -0500 Subject: [PATCH] checkPlugin: Make sure `package.json` ends with a newline --- bin/plugins/checkPlugin.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/plugins/checkPlugin.js b/bin/plugins/checkPlugin.js index bc53c9946..ec922ebc2 100755 --- a/bin/plugins/checkPlugin.js +++ b/bin/plugins/checkPlugin.js @@ -42,8 +42,11 @@ const execSync = (cmd, opts = {}) => (childProcess.execSync(cmd, { ...opts, }) || '').toString().replace(/\n+$/, ''); -const writePackageJson = - (obj) => fs.writeFileSync(`${pluginPath}/package.json`, JSON.stringify(obj, null, 2)); +const writePackageJson = (obj) => { + let s = JSON.stringify(obj, null, 2); + if (s.length && s.slice(s.length - 1) !== '\n') s += '\n'; + return fs.writeFileSync(`${pluginPath}/package.json`, s); +}; const prepareRepo = () => { let branch = execSync('git symbolic-ref HEAD');