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(engine): add support for disableScopeLowerCase #96

Merged
merged 1 commit into from Jan 28, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion engine.js
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
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
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