From 5210b1eb388f9c744b432401804f7e56e962f50d Mon Sep 17 00:00:00 2001 From: Stephen Zhou Date: Sat, 20 Apr 2024 23:20:34 +0800 Subject: [PATCH] fix: read and generate changelog before release --- package.json | 4 +++- src/index.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 66d3c7f..8c4d6ee 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,9 @@ }, "release-it": { "plugins": { - "./src/index.js": {} + "./src/index.js": { + "inFile": "CHANGELOG.md" + } }, "git": { "commitMessage": "chore: release ${version}", diff --git a/src/index.js b/src/index.js index 49743ba..8de10d8 100644 --- a/src/index.js +++ b/src/index.js @@ -198,6 +198,18 @@ class ReleaseItPnpmPlugin extends Plugin { } } + async beforeRelease() { + const { inFile } = this.options; + const isDryRun = this.options["dry-run"]; + + this.log.exec(`Writing changelog to ${inFile}`, isDryRun); + + if (inFile && !isDryRun) { + const { md } = await generate(); + await this.writeChangelog(md); + } + } + async release() { if (this.options?.disableRelease) return;