Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add configuration option upperCaseSubject #83

Merged
merged 1 commit into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Here are the options you can set in your `.cz-config.js`:
* **breakingPrefix**: {string, default 'BREAKING CHANGE:'}: Set a custom prefix for the breaking change block in commit messages.
* **footerPrefix**: {string, default 'ISSUES CLOSED:'}: Set a custom prefix for the footer block in commit messages. Set to empty string to remove prefix.
* **breaklineChar**: {string, default '|'}: It gets replaced with \n to create the breakline in your commit message. This is supported for fields `body` and `footer` at the moment.
* **upperCaseSubject**: { boolean, default false }: Capitalizes first subject letter if set to `true`

## Related tools
- (https://github.com/commitizen/cz-cli)
Expand Down
4 changes: 3 additions & 1 deletion questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ module.exports = {
return true;
},
filter(value) {
return value.charAt(0).toLowerCase() + value.slice(1);
const upperCaseSubject = config.upperCaseSubject || false;

return (upperCaseSubject ? value.charAt(0).toUpperCase() : value.charAt(0).toLowerCase()) + value.slice(1);
},
},
{
Expand Down
13 changes: 13 additions & 0 deletions spec/questionsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ describe('cz-customizable', () => {
).toEqual('Exceed limit: 100');
});

it('subject should be lowercased by default', () => {
config = {};
expect(getQuestion(5).filter('Some subject')).toEqual('some subject');
});

it('subject should be capitilized when config property "upperCaseSubject" is set to true', () => {
config = {
upperCaseSubject: true,
};

expect(getQuestion(5).filter('some subject')).toEqual('Some subject');
});

describe('optional fixOverride and allowBreakingChanges', () => {
it('should restrict BREAKING CHANGE question when config property "allowBreakingChanges" specifies array of types', () => {
config = {
Expand Down