diff --git a/.gitignore b/.gitignore index a47e9ebf..391388a0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ .idea/ node_modules/ npm-debug.log -yarn.lock \ No newline at end of file +yarn.lock +.vscode/ diff --git a/src/index.js b/src/index.js index ff11148c..c4e0549c 100644 --- a/src/index.js +++ b/src/index.js @@ -28,6 +28,10 @@ const makeAffectsLine = function (answers) { return ''; }; +const emojis = { + style: '💄' +}; + module.exports = { prompter (cz, commit) { let promptQuestions = questions; @@ -47,7 +51,8 @@ module.exports = { width: MAX_LINE_WIDTH }; - const head = answers.type + ': ' + answers.subject; + const emojiPrefix = emojis[answers.type] ? emojis[answers.type] + ' ' : ''; + const head = answers.type + ': ' + emojiPrefix + answers.subject; const affectsLine = makeAffectsLine(answers); // Wrap these lines at MAX_LINE_WIDTH character diff --git a/src/prompt/questions.js b/src/prompt/questions.js index 31330d05..7251ee44 100644 --- a/src/prompt/questions.js +++ b/src/prompt/questions.js @@ -1,3 +1,5 @@ +const types = require('../types').types; + const MAX_SUBJECT_LENGTH = 64; const MIN_SUBJECT_LENGTH = 3; const MIN_SUBJECT_LENGTH_ERROR_MESSAGE = `The subject must have at least ${MIN_SUBJECT_LENGTH} characters`; @@ -5,42 +7,15 @@ const MIN_SUBJECT_LENGTH_ERROR_MESSAGE = `The subject must have at least ${MIN_S const questions = [ { choices: [ - { - name: 'feat: A new feature', - value: 'feat' - }, - { - name: 'fix: A bug fix', - value: 'fix' - }, - { - name: 'docs: Documentation only changes', - value: 'docs' - }, - { - name: 'style: Markup-only changes (white-space, formatting, missing semi-colons, etc)', - value: 'style' - }, - { - name: 'refactor: A code change that neither fixes a bug or adds a feature', - value: 'refactor' - }, - { - name: 'perf: A code change that improves performance', - value: 'perf' - }, - { - name: 'test: Adding missing tests', - value: 'test' - }, - { - name: 'chore: Build process or auxiliary tool changes', - value: 'chore' - }, - { - name: 'ci: CI related changes', - value: 'ci' - } + types.test, + types.feat, + types.fix, + types.chore, + types.docs, + types.refactor, + types.style, + types.ci, + types.perf ], message: 'Select the type of change that you\'re committing:', name: 'type', diff --git a/src/types.js b/src/types.js new file mode 100644 index 00000000..70985d4d --- /dev/null +++ b/src/types.js @@ -0,0 +1,39 @@ +exports.types = { + chore: { + name: 'Build process or auxiliary tool changes', + value: 'chore' + }, + ci: { + name: 'CI related changes', + value: 'ci' + }, + docs: { + name: 'Documentation only changes', + value: 'docs' + }, + feat: { + name: 'A new feature', + value: 'feat' + }, + fix: { + name: 'A bug fix', + value: 'fix' + }, + perf: { + name: 'A code change that improves performance', + value: 'perf' + }, + refactor: { + name: 'A code change that neither fixes a bug or adds a feature', + value: 'refactor' + }, + style: { + emoji: '💄', + name: 'Markup-only changes (white-space, formatting, missing semi-colons, etc)', + value: 'style' + }, + test: { + name: 'Adding missing tests', + value: 'test' + } +};