diff --git a/src/__tests__/__snapshots__/files.test.js.snap b/src/__tests__/__snapshots__/files.test.js.snap index b84084a..27bcebb 100644 --- a/src/__tests__/__snapshots__/files.test.js.snap +++ b/src/__tests__/__snapshots__/files.test.js.snap @@ -3,6 +3,7 @@ exports[`Files should create, and update CHANGELOG.md version with a comparison urls: urls and paths, no release commit 1`] = ` "# Changelog All notable changes to this project will be documented in this file. + ## 1.0.0 (2022-10-01) ### Features @@ -23,6 +24,7 @@ All notable changes to this project will be documented in this file. exports[`Files should create, and update CHANGELOG.md version with a comparison urls: urls and paths, release commit 1`] = ` "# Changelog All notable changes to this project will be documented in this file. + ## [1.0.0](https://localhost/lorem/ipsum/comparmock/REALFIRST2345d421231231312312345dca11235...LASTg45b597123453031234555b6d25574ccacee) (2022-10-01) ### Features @@ -43,6 +45,7 @@ All notable changes to this project will be documented in this file. exports[`Files should create, and update CHANGELOG.md version with a comparison urls: urls and paths, release commit, no markdown links 1`] = ` "# Changelog All notable changes to this project will be documented in this file. + ## 1.0.0 (2022-10-01) ### Features @@ -63,6 +66,7 @@ All notable changes to this project will be documented in this file. exports[`Files should create, and update a basic CHANGELOG.md: changelog 1`] = ` "# Changelog All notable changes to this project will be documented in this file. + ## ¯\\_(ツ)_/¯ (2022-10-01) ### Features diff --git a/src/__tests__/__snapshots__/index.test.js.snap b/src/__tests__/__snapshots__/index.test.js.snap index 9318108..ea163e9 100644 --- a/src/__tests__/__snapshots__/index.test.js.snap +++ b/src/__tests__/__snapshots__/index.test.js.snap @@ -4,6 +4,7 @@ exports[`Commit Changelog should parse commits to produce a CHANGELOG.md with an { "changelog": "# Changelog All notable changes to this project will be documented in this file. + ## ["15.0.0"] (2022-10-01) ", @@ -20,6 +21,7 @@ exports[`Commit Changelog should parse commits to produce a CHANGELOG.md: Commit { "changelog": "# Changelog All notable changes to this project will be documented in this file. + ## ["[\\"0.0.100\\",\\"patch\\"]"] (2022-10-01) ", diff --git a/src/files.js b/src/files.js index 7fe4aed..ce510ac 100644 --- a/src/files.js +++ b/src/files.js @@ -45,8 +45,8 @@ const updateChangelog = ( if (existsSync(changelogPath)) { const [tempHeader, ...tempBody] = readFileSync(changelogPath, 'utf-8').split('##'); - header = tempHeader; - body = (tempBody.length && `## ${tempBody.join('##')}`) || body; + header = tempHeader.trim(); + body = (tempBody.length && `## ${tempBody.join('##').trim()}`) || body; } else if (!isDryRun) { writeFileSync(changelogPath, ''); } @@ -67,7 +67,7 @@ const updateChangelog = ( } const updatedBody = `## ${version} (${systemTimestamp})\n${displayCommits}`; - const output = `${header}\n${updatedBody}\n${body}`; + const output = `${header}\n\n${updatedBody}\n${body}`; if (isDryRun) { console.info(`\n${updatedBody}`);