From e7bd5462966d00acb03aca394836b5427513681c Mon Sep 17 00:00:00 2001 From: Vikash Agrawal Date: Tue, 28 Jan 2020 18:22:10 +0530 Subject: [PATCH] feat(engine): add support for disableScopeLowerCase (#96) --- engine.js | 4 +++- engine.test.js | 21 ++++++++++++++++++++- index.js | 2 ++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/engine.js b/engine.js index 098ea67e..873778a4 100644 --- a/engine.js +++ b/engine.js @@ -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(); } }, { diff --git a/engine.test.js b/engine.test.js index ca04880c..4a42becd 100644 --- a/engine.test.js +++ b/engine.test.js @@ -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' + @@ -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({ @@ -298,6 +314,9 @@ describe('defaults', function() { ) ).to.equal(issues); }); + it('disableScopeLowerCase default', function() { + expect(questionDefault('disableScopeLowerCase')).to.be.undefined; + }); }); describe('prompts', function() { diff --git a/index.js b/index.js index bbc44f59..0a03cf52 100644 --- a/index.js +++ b/index.js @@ -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)) ||