Skip to content

Commit

Permalink
driveby semi-colon addition and use regex
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieDanielson committed Aug 15, 2024
1 parent 0c2cad1 commit c626c3a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/extract-latest-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const fs = require('fs');
function extractLatestChangelog(changelogPath) {
const changelog = fs.readFileSync(changelogPath).toString();
// Matches everything from the first entry at h2 ('##') followed by a space and a non-prerelease semver version
// until the next entry at h2.
const firstReleaseNoteEntryExp = /^## \d+\.\d+\.\d\n.*?(?=^## )/ms;
// append the changelog with a dummy entry to ensure new packages match the regex
return (changelog + '\n## ').match(firstReleaseNoteEntryExp)[0];
}
// until the next entry at h2 or the end of the file (useful for first entry).
const firstReleaseNoteEntryExp = /^## \d+\.\d+\.\d\n.*?((?=^## )|$(?![\r\n]))/ms;

return changelog.match(firstReleaseNoteEntryExp)[0];
};

fs.mkdirSync('./.tmp/', {
recursive: true
});

const notesFile = './.tmp/release-notes.md'
const notesFile = './.tmp/release-notes.md';
const changelogFilePaths = process.argv.slice(2);
fs.writeFileSync(notesFile, changelogFilePaths.map(filePath => extractLatestChangelog(filePath)).join('\n'));

0 comments on commit c626c3a

Please sign in to comment.