Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
feat: 🎸 added disableEmojis on config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio committed Jun 11, 2019
1 parent 78ee24c commit 448873e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ in your repo. Below is default config:

```js
module.exports = {
"disableEmoji": false,
"list": [
"test",
"feat",
Expand Down
23 changes: 16 additions & 7 deletions lib/formatCommitMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
const emoji = config.types[answers.type].emoji;
const emojiPrefix = emoji ? emoji + ' ' : '';

head = answers.type + scope + ': ' + emojiPrefix + answers.subject;
}

head = answers.type + scope + ': ' + answers.subject;

const affectsLine = makeAffectsLine(answers);

// Wrap these lines at MAX_LINE_WIDTH character
Expand All @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions lib/questions/type.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit 448873e

Please sign in to comment.