From 178e00196af696c4bab3dec62df38b658aa7b543 Mon Sep 17 00:00:00 2001 From: Andrew Goode Date: Tue, 31 May 2016 19:35:08 -0400 Subject: [PATCH] fix: append line feed to end of package.json (#42) --- index.js | 2 +- test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 0c54553cd..632b9a8f2 100755 --- a/index.js +++ b/index.js @@ -61,7 +61,7 @@ conventionalRecommendedBump({ newVersion = semver.inc(pkg.version, release.releaseAs) checkpoint('bumping version in package.json from %s to %s', [pkg.version, newVersion]) pkg.version = newVersion - fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2), 'utf-8') + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8') } else { console.log(chalk.red(figures.cross) + ' skip version bump on first release') } diff --git a/test.js b/test.js index e89f45df1..5c97cbf1d 100644 --- a/test.js +++ b/test.js @@ -155,4 +155,13 @@ describe('cli', function () { // check annotated tag message shell.exec('git tag -l -n1 v1.1.0').stdout.should.match(/chore\(release\): 1\.1\.0/) }) + + it('appends line feed at end of package.json', function () { + writePackageJson('1.0.0') + + shell.exec(cliPath).code.should.equal(0) + + var pkgJson = fs.readFileSync('package.json', 'utf-8') + pkgJson.should.equal(['{', ' "version": "1.0.1"', '}', ''].join('\n')) + }) })