Skip to content

Commit

Permalink
fix: handle 'no commits' in default template
Browse files Browse the repository at this point in the history
  • Loading branch information
maximousblk authored Mar 3, 2021
1 parent 02e1492 commit f0c5cb3
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,35 @@ export async function getDefaultChangelog(

const title = release?.name ? `# ${release?.name}\n\n` : "";

const counts = changes
.map(({ emoji, count }) => `\`${emoji} ${count}\``)
.join(" ");
const counts = changes.map(({ emoji, count }) => `\`${emoji} ${count}\``);

const stats = [
`\`📆 ${release?.date ?? formatTime(new Date(), "dd.MM.yyyy")}\``,
`\`🏷️ ${release?.tag ?? "UNRELEASED"}\``,
`\`💾 ${_meta.commits.head.shortSha.toUpperCase()}\``,
counts,
`${counts.join(" ")}`,
`\`👥 ${_meta.contributors.length}\``,
].join(" ");

return `${title}${stats}
${
changes
.map(({ emoji, title, commits }) => {
const header = `## ${emoji} ${title}`;
const changes = commits
.map(({ shortSha, url, header, author }) => {
return `- [\`${shortSha.toUpperCase()}\`](${url}) ${header} (${author})`;
})
.join("\n");
return `\n${header}\n\n${changes}`;
})
.join("\n")
changes.length
? changes
.map(({ emoji, title, commits }) => {
const header = `## ${emoji} ${title}`;
const changes = commits
.map(({ shortSha, url, header, author }) => {
return `- [\`${shortSha.toUpperCase()}\`](${url}) ${header} (${author})`;
})
.join("\n");
return `\n${header}\n\n${changes}`;
})
.join("\n")
: "\nNo changes"
}
## 👥 Contributors
${_meta.contributors.map((name) => `- ${name}`).join("\n")}
${_meta.contributors.map((name) => `- ${name}`).join("\n") || "No contributors"}
`;
}

0 comments on commit f0c5cb3

Please sign in to comment.