Skip to content

Commit

Permalink
feat(engine): add support for disableScopeLowerCase (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivikash authored and jimthedev committed Jan 28, 2020
1 parent 5a371c1 commit e7bd546
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 3 additions & 1 deletion engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ module.exports = function(options) {
'What is the scope of this change (e.g. component or file name): (press enter to skip)',
default: options.defaultScope,
filter: function(value) {
return value.trim().toLowerCase();
return options.disableScopeLowerCase
? value.trim()
: value.trim().toLowerCase();
}
},
{
Expand Down
21 changes: 20 additions & 1 deletion engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var defaultOptions = {
var type = 'func';
var scope = 'everything';
var subject = 'testing123';
var subject2 = 'after the fall, I was gone';
var longBody =
'a a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a' +
'a a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a aa a' +
Expand Down Expand Up @@ -85,6 +84,23 @@ describe('commit message', function() {
})
).to.equal(`${type}(${scope}): ${subject}\n\n${body}`);
});
it('header and body w/ uppercase scope', function() {
var upperCaseScope = scope.toLocaleUpperCase();
expect(
commitMessage(
{
type,
scope: upperCaseScope,
subject,
body
},
{
...defaultOptions,
disableScopeLowerCase: true
}
)
).to.equal(`${type}(${upperCaseScope}): ${subject}\n\n${body}`);
});
it('header, body and issues w/ out scope', function() {
expect(
commitMessage({
Expand Down Expand Up @@ -298,6 +314,9 @@ describe('defaults', function() {
)
).to.equal(issues);
});
it('disableScopeLowerCase default', function() {
expect(questionDefault('disableScopeLowerCase')).to.be.undefined;
});
});

describe('prompts', function() {
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var options = {
defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
defaultBody: process.env.CZ_BODY || config.defaultBody,
defaultIssues: process.env.CZ_ISSUES || config.defaultIssues,
disableScopeLowerCase:
process.env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
maxHeaderWidth:
(process.env.CZ_MAX_HEADER_WIDTH &&
parseInt(process.env.CZ_MAX_HEADER_WIDTH)) ||
Expand Down

0 comments on commit e7bd546

Please sign in to comment.