diff --git a/src/prepare.test.ts b/src/prepare.test.ts index 289a89e..6b45e11 100644 --- a/src/prepare.test.ts +++ b/src/prepare.test.ts @@ -32,6 +32,7 @@ describe('prepare', function () { ); const [, newChangelog] = mocks.writeFileSync.mock.lastCall; expect(newChangelog).to.eq(`# A Totally ficticious Changelog + ## v1.0.0 thing v1.0.0 (major) @@ -46,4 +47,36 @@ thing v1.0.0 (major) `); }); }); + + it('updates changelog correctly with case insensitive CHANGELOG', function () { + mocks.readFileSync.mockReturnValue(`# A Totally ficticious CHANGELOG + +## Some Old version + +- added some features +- spent a lot of time trying to figure out releases (if only there was a tool to help with that) +`); + updateChangelog( + `## v1.0.0 + +- added release-plan (how did I live without it!?) +- releasing initial working version`, + new Map([['thing', { newVersion: 'v1.0.0', impact: 'major' }]]) as any, + ); + const [, newChangelog] = mocks.writeFileSync.mock.lastCall; + expect(newChangelog).to.eq(`# A Totally ficticious CHANGELOG + +## v1.0.0 + +thing v1.0.0 (major) + +- added release-plan (how did I live without it!?) +- releasing initial working version + +## Some Old version + +- added some features +- spent a lot of time trying to figure out releases (if only there was a tool to help with that) +`); + }); }); diff --git a/src/prepare.ts b/src/prepare.ts index 2600ba7..277f9b7 100644 --- a/src/prepare.ts +++ b/src/prepare.ts @@ -6,7 +6,7 @@ import fsExtra from 'fs-extra'; const { readJSONSync, writeJSONSync } = fsExtra; -const changelogPreamblePattern = /#.*Changelog.*$/; +const changelogPreamblePattern = /#.*Changelog.*$/i; export function updateChangelog( newChangelogContent: string, @@ -38,7 +38,7 @@ export function updateChangelog( writeFileSync( targetChangelogFile, oldChangelogContent[0] + - '\n' + + '\n\n' + newOutput + oldChangelogContent.slice(1).join('\n'), );