diff --git a/.git-cz.json b/.git-cz.json new file mode 100644 index 00000000..92137901 --- /dev/null +++ b/.git-cz.json @@ -0,0 +1,3 @@ +{ + "disableEmoji": false +} diff --git a/README.md b/README.md index 61f70ecd..15f4e10f 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ in your repo. Below is default config: ```js module.exports = { + "disableEmoji": false, "list": [ "test", "feat", diff --git a/lib/formatCommitMessage.js b/lib/formatCommitMessage.js index 46cb827f..cb9998ea 100644 --- a/lib/formatCommitMessage.js +++ b/lib/formatCommitMessage.js @@ -19,17 +19,22 @@ const formatCommitMessage = (state) => { trim: true, width: MAX_LINE_WIDTH }; - - const emoji = config.types[answers.type].emoji; - const emojiPrefix = emoji ? emoji + ' ' : ''; - + let head = ''; let scope = ''; if (answers.scope && answers.scope !== 'none') { scope = `(${answers.scope})`; } - const head = answers.type + scope + ': ' + emojiPrefix + answers.subject; + if (config.disableEmoji) { + head = answers.type + scope + ': ' + answers.subject; + } else { + const emoji = config.types[answers.type].emoji; + const emojiPrefix = emoji ? emoji + ' ' : ''; + + head = answers.type + scope + ': ' + emojiPrefix + answers.subject; + } + const affectsLine = makeAffectsLine(answers); // Wrap these lines at MAX_LINE_WIDTH character @@ -44,11 +49,15 @@ const formatCommitMessage = (state) => { } if (breaking) { - msg += '\n\nBREAKING CHANGE: ' + config.breakingChangePrefix + breaking; + const breakingEmoji = config.disableEmoji ? config.breakingChangePrefix : ''; + + msg += '\n\nBREAKING CHANGE: ' + breakingEmoji + breaking; } if (issues) { - msg += '\n\n' + config.closedIssuePrefix + 'Closes: ' + issues; + const closedIssueEmoji = config.disableEmoji ? config.closedIssuePrefix : ''; + + msg += '\n\n' + closedIssueEmoji + 'Closes: ' + issues; } return msg; diff --git a/lib/questions/type.js b/lib/questions/type.js index fd04b67a..891c0c0c 100644 --- a/lib/questions/type.js +++ b/lib/questions/type.js @@ -1,18 +1,19 @@ const pad = require('pad-right'); -const typeToListItem = ({description, emoji, value}) => { - const prefix = emoji ? emoji + ' ' : ''; +const typeToListItem = ({types, disableEmoji}, type) => { + const {description, emoji, value} = types[type]; + const prefix = emoji && !disableEmoji ? emoji + ' ' : ''; return { name: prefix + pad(value + ':', 12, ' ') + description, value - } + }; }; exports.createQuestion = (state) => { const {config} = state; const question = { - choices: config.list.map((type) => typeToListItem(config.types[type])), + choices: config.list.map((type) => typeToListItem(config, type)), message: 'Select the type of change that you\'re committing:', name: 'type', type: 'list'