diff options
author | 2023-04-14 18:44:22 +0200 | |
---|---|---|
committer | 2023-04-14 21:08:43 +0200 | |
commit | dbad7730f902cfc7bfddfe63afa357d92b0f9e92 (patch) | |
tree | 1d90477b42e71ba8cb01879f7a738ab9cebf211e /scripts/shared/changelog.mjs | |
parent | 85cb0ffabdb70c8983858720fb101d315f476bee (diff) | |
download | it-tools-dbad7730f902cfc7bfddfe63afa357d92b0f9e92.tar.gz it-tools-dbad7730f902cfc7bfddfe63afa357d92b0f9e92.tar.zst it-tools-dbad7730f902cfc7bfddfe63afa357d92b0f9e92.zip |
chore(release): create a github release on new version
Diffstat (limited to 'scripts/shared/changelog.mjs')
-rw-r--r-- | scripts/shared/changelog.mjs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/shared/changelog.mjs b/scripts/shared/changelog.mjs new file mode 100644 index 0000000..d5bf73c --- /dev/null +++ b/scripts/shared/changelog.mjs @@ -0,0 +1,15 @@ +import { readFile, writeFile } from 'fs/promises'; + +export { addToChangelog }; + +async function addToChangelog({ changelog, version, changelogPath = './CHANGELOG.md' }) { + const changelogContent = await readFile(changelogPath, 'utf-8'); + const versionTitle = `## Version ${version}`; + + if (changelogContent.includes(versionTitle)) { + throw new Error(`Version ${version} already exists in the changelog`); + } + + const newChangeLogContent = changelogContent.replace('## ', `${versionTitle}\n\n${changelog}\n\n## `); + await writeFile(changelogPath, newChangeLogContent, 'utf-8'); +} |