From c626c3a0eb940bbfc90d817793c355fb1ab67d32 Mon Sep 17 00:00:00 2001 From: JamieDanielson Date: Tue, 13 Aug 2024 17:36:45 -0400 Subject: [PATCH] driveby semi-colon addition and use regex --- scripts/extract-latest-release-notes.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/extract-latest-release-notes.js b/scripts/extract-latest-release-notes.js index 1a8d72e5..602ebcac 100644 --- a/scripts/extract-latest-release-notes.js +++ b/scripts/extract-latest-release-notes.js @@ -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'));