From 507eececd959c491f5730efa0547f548a57c9379 Mon Sep 17 00:00:00 2001 From: Pierre-Denis Vanduynslager Date: Sun, 27 Aug 2017 01:24:50 -0400 Subject: [PATCH] feat(preset): Add emoji to changelog group titles --- src/lib/commit-transform.js | 2 +- test/preset.test.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/lib/commit-transform.js b/src/lib/commit-transform.js index 94d78ea..16bf85d 100644 --- a/src/lib/commit-transform.js +++ b/src/lib/commit-transform.js @@ -17,7 +17,7 @@ module.exports = (commit, context) => { } if (types[commit.type] && (types[commit.type].changelog || (commit.notes && commit.notes.length > 0))) { - commit.type = types[commit.type].title; + commit.type = `${types[commit.type].emoji ? `${types[commit.type].emoji} ` : ''}${types[commit.type].title}`; } else { return null; } diff --git a/test/preset.test.js b/test/preset.test.js index a5d8367..e4fa2d9 100644 --- a/test/preset.test.js +++ b/test/preset.test.js @@ -16,6 +16,18 @@ test.serial('Include only commits with "changelog" set to "true"', async t => { t.notRegex(log, /First fix/); }); +test.serial('Include type emoji in group titles', async t => { + const log = await changelog(['fix(scope1): First fix', 'feat(scope2): Second feature'], { + types: { + feat: {title: 'Feature title', changelog: true, emoji: '✨'}, + fix: {title: 'Fix title', changelog: true, emoji: '🐛'}, + }, + }); + + t.regex(log, /### ✨ Feature title/); + t.regex(log, /### 🐛 Fix title/); +}); + test.serial('Include commits with breaking changes even if "changelog" is not set to "true"', async t => { const log = await changelog( [