Skip to content

Commit bffae1c

Browse files
committed
Use withChangelog I/O helper
1 parent 1ee3265 commit bffae1c

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎pr-checks/changenotes.mts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import {
1212
addBodyLinesToUnreleasedSection,
1313
parseChangelog,
1414
renderChangelog,
15+
withChangelog,
1516
} from "./changelog";
1617
import { isValidAllChangenoteFiles } from "./changelog/validate.mjs";
17-
import { CHANGELOG_FILE, CHANGENOTES_DIR } from "./config";
18+
import { CHANGENOTES_DIR } from "./config";
1819

1920
const entryPoint = process.argv[1];
2021
if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) {
@@ -70,10 +71,11 @@ function flush(): number {
7071
return content.trim();
7172
});
7273

73-
const changelogContents = fs.readFileSync(CHANGELOG_FILE).toString();
74-
const changelog = parseChangelog(changelogContents);
75-
addBodyLinesToUnreleasedSection(changelog, changenotes);
76-
fs.writeFileSync(CHANGELOG_FILE, renderChangelog(changelog));
74+
withChangelog((contents) => {
75+
const changelog = parseChangelog(contents);
76+
addBodyLinesToUnreleasedSection(changelog, changenotes);
77+
return renderChangelog(changelog);
78+
}, {});
7779

7880
// Delete changenotes only after successful processing.
7981
for (const p of changenotePaths) {

0 commit comments

Comments
 (0)