Skip to content

Commit eff597a

Browse files
authored
feat: ability to insert text before git log in releases.md (#46)
1 parent cbde2e7 commit eff597a

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

releases_md.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,34 @@ export class ReleasesMdFile {
4040
return this.#fileText;
4141
}
4242

43-
updateWithGitLog(
44-
{ gitLog, version, date }: {
45-
gitLog: GitLogOutput;
46-
version: string;
47-
date?: Date;
48-
},
49-
) {
43+
updateWithGitLog({
44+
gitLog,
45+
version,
46+
date,
47+
bodyPreText,
48+
}: {
49+
gitLog: GitLogOutput;
50+
version: string;
51+
date?: Date;
52+
/** Text to insert after the title and before the git log. */
53+
bodyPreText?: string;
54+
}) {
5055
const insertText = getInsertText();
5156
this.#updateText(this.#fileText.replace(/^### /m, insertText + "\n\n### "));
5257

5358
function getInsertText() {
5459
const formattedGitLog = gitLog.formatForReleaseMarkdown();
5560
const formattedDate = getFormattedDate(date ?? new Date());
5661

57-
return `### ${version} / ${formattedDate}\n\n` +
58-
`${formattedGitLog}`;
62+
let text = `### ${version} / ${formattedDate}\n\n`;
63+
64+
if (bodyPreText != null && bodyPreText.length > 0) {
65+
text += `${bodyPreText}\n\n`;
66+
}
67+
68+
text += formattedGitLog;
69+
70+
return text;
5971

6072
function getFormattedDate(date: Date) {
6173
const formattedMonth = padTwoDigit(date.getMonth() + 1);

0 commit comments

Comments
 (0)