diff --git a/src/commands/default.ts b/src/commands/default.ts index 6ea7894e..ccd749d0 100644 --- a/src/commands/default.ts +++ b/src/commands/default.ts @@ -26,6 +26,7 @@ export default async function defaultMain(args: Argv) { output: args.output, newVersion: typeof args.r === "string" ? args.r : undefined, noAuthors: args.noAuthors, + hideAuthorEmail: args.hideAuthorEmail, }); if (args.clean) { diff --git a/src/markdown.ts b/src/markdown.ts index e8f705e2..195bdeaf 100644 --- a/src/markdown.ts +++ b/src/markdown.ts @@ -97,11 +97,11 @@ export async function generateMarkDown( (e) => !e.includes("noreply.github.com") ); const email = - config.hideAuthorEmail !== true && _email ? `<${_email}>` : ""; + config.hideAuthorEmail !== true && _email ? ` <${_email}>` : ""; const github = i.github - ? `([@${i.github}](https://github.com/${i.github}))` + ? ` ([@${i.github}](https://github.com/${i.github}))` : ""; - return `- ${i.name} ${github || email}`; + return `- ${i.name}${github || email || ""}`; }) ); } diff --git a/test/contributors.test.ts b/test/contributors.test.ts index fcb04e8e..a34e22c5 100644 --- a/test/contributors.test.ts +++ b/test/contributors.test.ts @@ -70,4 +70,42 @@ describe("contributors", () => { - **scope:** Update dependencies" `); }); + + test("should skip author email addresses with hideAuthorEmail config", async () => { + const config = await loadChangelogConfig(process.cwd(), { + from: "1.0.0", + newVersion: "2.0.0", + hideAuthorEmail: true, + }); + const contents = await generateMarkDown(testCommits, config); + + expect(contents).toMatchInlineSnapshot(` + "## v2.0.0 + + [compare changes](https://github.com/unjs/changelogen/compare/1.0.0...v2.0.0) + + ### 🚀 Enhancements + + - **scope:** Add feature + + ### 🩹 Fixes + + - **scope:** Resolve bug + + ### 📖 Documentation + + - **scope:** Update documentation + + ### 🏡 Chore + + - **scope:** Update dependencies + + ### ❤️ Contributors + + - John Doe ([@brainsucker](https://github.com/brainsucker)) + - Jane Smith + - Alice Johnson + - Bob Williams" + `); + }); });