fix(aidocs): Fix changelog generation by handling leading newlines

This commit is contained in:
2024-06-24 00:01:36 +02:00
parent a22c400355
commit d962e17c18
3 changed files with 13 additions and 2 deletions

View File

@ -27,7 +27,10 @@ export class Commit {
smartgitInstance,
this.projectDir
);
const diffStringArray = await gitRepo.getUncommittedDiff(['pnpm-lock.yaml', 'package-lock.json']);
const diffStringArray = await gitRepo.getUncommittedDiff([
'pnpm-lock.yaml',
'package-lock.json',
]);
const projectContext = new ProjectContext(this.projectDir);
let contextString = await projectContext.update();
contextString = `
@ -116,6 +119,9 @@ ${JSON.stringify(commitMessages, null, 2)}
}
let oldChangelog = previousChangelog.contents.toString().replace('# Changelog\n\n', '');
if (oldChangelog.startsWith('\n')) {
oldChangelog = oldChangelog.replace('\n', '');
}
let newDateString = new plugins.smarttime.ExtendedDate().exportToHyphedSortableDate();
let newChangelog = `# Changelog\n\n${`## ${newDateString} - {{nextVersion}} - {{nextVersionScope}}
{{nextVersionMessage}}