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

Commit

Permalink
refactor: 💡 default => user can dictate spaces (!emoji)
Browse files Browse the repository at this point in the history
+ update default format to match repo

✅ Closes: 81
  • Loading branch information
JeromeFitz committed Feb 27, 2021
1 parent 5e998cf commit 54b32ed
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .git-cz.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"disableEmoji": false,
"format": "{emoji} {scope}: {subject}"
"format": "{type}{scope}: {emoji}{subject}"
}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions lib/defaults.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const format = '{type}{scope}: {emoji}{subject}';

const types = {
chore: {
description: 'Build process or auxiliary tool changes',
Expand Down Expand Up @@ -65,8 +67,7 @@ const list = [
];

// https://github.com/angular/angular/blob/master/CONTRIBUTING.md#scope
const scopes = [
];
const scopes = [];

const questions = [
'type',
Expand All @@ -82,6 +83,7 @@ module.exports = {
breakingChangePrefix: '🧨 ',
closedIssueMessage: 'Closes: ',
closedIssuePrefix: '✅ ',
format,
list,
maxMessageLength: 64,
minMessageLength: 3,
Expand Down
5 changes: 3 additions & 2 deletions lib/formatCommitMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 54b32ed

Please sign in to comment.