diff --git a/.git-cz.json b/.git-cz.json index 99630e77..3a247a1e 100644 --- a/.git-cz.json +++ b/.git-cz.json @@ -1,4 +1,4 @@ { "disableEmoji": false, - "format": "{emoji} {scope}: {subject}" + "format": "{type}{scope}: {emoji}{subject}" } diff --git a/README.md b/README.md index a9f631da..f235905c 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Below is default config: ```js module.exports = { disableEmoji: false, - format: '{type} {scope}: {subject}', + format: '{type}{scope}: {emoji}{subject}', list: ['test', 'feat', 'fix', 'chore', 'docs', 'refactor', 'style', 'ci', 'perf'], maxMessageLength: 64, minMessageLength: 3, @@ -184,12 +184,12 @@ This allows the message to be easier to read on GitHub as well as in various git ### Format -By default the subject format is: `{type} {scope}: {subject}` +By default the subject format is: `{type}{scope}: {subject}` Configuring the `format` field in `.git-cz.json` you can customize your own: -- `{emoji} {type} {scope} {subject}` -- `{type} {scope}: {emoji} {subject}` +- `{type}{scope}: {emoji}{subject}` +- `{emoji}{scope} {subject}` ### Type diff --git a/lib/defaults.js b/lib/defaults.js index 3f076a0a..68dfdf7c 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -1,3 +1,5 @@ +const format = '{type}{scope}: {emoji}{subject}'; + const types = { chore: { description: 'Build process or auxiliary tool changes', @@ -65,8 +67,7 @@ const list = [ ]; // https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope -const scopes = [ -]; +const scopes = []; const questions = [ 'type', @@ -82,6 +83,7 @@ module.exports = { breakingChangePrefix: '🧨 ', closedIssueMessage: 'Closes: ', closedIssuePrefix: '✅ ', + format, list, maxMessageLength: 64, minMessageLength: 3, diff --git a/lib/formatCommitMessage.js b/lib/formatCommitMessage.js index 8cd276b4..a3869524 100644 --- a/lib/formatCommitMessage.js +++ b/lib/formatCommitMessage.js @@ -27,7 +27,7 @@ const formatCommitMessage = (state) => { const subject = answers.subject.trim(); const type = answers.type; - const format = config.format || '{emoji} {scope}: {subject}'; + const format = config.format || '{type}{scope}: {emoji}{subject}'; const affectsLine = makeAffectsLine(answers); @@ -36,8 +36,9 @@ const formatCommitMessage = (state) => { const breaking = wrap(answers.breaking, wrapOptions); const issues = wrap(answers.issues, wrapOptions); + // @note(emoji) Add space after emoji (breakingChangePrefix/closedIssueEmoji) const head = format - .replace(/\{emoji\}/g, emoji) + .replace(/\{emoji\}/g, config.disableEmoji ? '' : emoji + ' ') .replace(/\{scope\}/g, scope) .replace(/\{subject\}/g, subject) .replace(/\{type\}/g, type);