fix(mod_commit): Handle edge case for empty version details in changelog formatting

This commit is contained in:
Philipp Kunz 2024-06-23 23:41:19 +02:00
parent 8199c6c2cc
commit 377fa83fe7
3 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2024-06-23 - 1.9.120 - fix(mod_commit)
Handle edge case for empty version details in changelog formatting
- Added check for the length of the recommendedNextVersionDetails array
- Ensure no extra newline in changelog if there are no version details
## 2024-06-23 - 1.9.119 - fix(dependencies) ## 2024-06-23 - 1.9.119 - fix(dependencies)
Update @git.zone/tsdoc to v1.3.8 Update @git.zone/tsdoc to v1.3.8

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/cli', name: '@git.zone/cli',
version: '1.9.119', version: '1.9.120',
description: 'A CLI toolbelt to streamline local development cycles by using various gitzone utilities.' description: 'A CLI toolbelt to streamline local development cycles by using various gitzone utilities.'
} }

View File

@ -74,7 +74,11 @@ export const run = async (argvArg: any) => {
changelog = changelog.replaceAll('{{nextVersion}}', (await commitInfo.getNextPlannedVersion()).versionString); changelog = changelog.replaceAll('{{nextVersion}}', (await commitInfo.getNextPlannedVersion()).versionString);
changelog = changelog.replaceAll('{{nextVersionScope}}', `${await answerBucket.getAnswerFor('commitType')}(${await answerBucket.getAnswerFor('commitScope')})`); changelog = changelog.replaceAll('{{nextVersionScope}}', `${await answerBucket.getAnswerFor('commitType')}(${await answerBucket.getAnswerFor('commitScope')})`);
changelog = changelog.replaceAll('{{nextVersionMessage}}', nextCommitObject.recommendedNextVersionMessage); changelog = changelog.replaceAll('{{nextVersionMessage}}', nextCommitObject.recommendedNextVersionMessage);
if (nextCommitObject.recommendedNextVersionDetails?.length > 0) {
changelog = changelog.replaceAll('{{nextVersionDetails}}', '- ' + nextCommitObject.recommendedNextVersionDetails.join('\n- ')); changelog = changelog.replaceAll('{{nextVersionDetails}}', '- ' + nextCommitObject.recommendedNextVersionDetails.join('\n- '));
} else {
changelog = changelog.replaceAll('\n\n{{nextVersionDetails}}', '');
}
await plugins.smartfile.memory.toFs(changelog, plugins.path.join(paths.cwd, `changelog.md`)); await plugins.smartfile.memory.toFs(changelog, plugins.path.join(paths.cwd, `changelog.md`));