Skip to content

Commit

Permalink
Merge pull request #51 from embroider-build/forgiving-changelog
Browse files Browse the repository at this point in the history
Make changelog header discovery more forgiving (case-insensitive)
  • Loading branch information
mansona authored Jan 24, 2024
2 parents cfbbc4d + 9967af9 commit 2565c8f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/prepare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
`);
});
});
4 changes: 2 additions & 2 deletions src/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -38,7 +38,7 @@ export function updateChangelog(
writeFileSync(
targetChangelogFile,
oldChangelogContent[0] +
'\n' +
'\n\n' +
newOutput +
oldChangelogContent.slice(1).join('\n'),
);
Expand Down

0 comments on commit 2565c8f

Please sign in to comment.