diff --git a/buildCommit.js b/buildCommit.js index d17d7ff..c99e3f0 100644 --- a/buildCommit.js +++ b/buildCommit.js @@ -43,7 +43,7 @@ const addFooter = (footer, config) => { const footerPrefix = config && config.footerPrefix ? config.footerPrefix : 'ISSUES CLOSED:'; - return `\n\n${footerPrefix} ${addBreaklinesIfNeeded(footer, config.breaklineChar)}`; + return `\n\n${footerPrefix}${config.addWhiteSpaceToFooterPrefix === false ? '' : ' '}${addBreaklinesIfNeeded(footer, config.breaklineChar)}`; }; const escapeSpecialChars = result => { diff --git a/cz-config-EXAMPLE.js b/cz-config-EXAMPLE.js index 2fedffd..54aafb0 100644 --- a/cz-config-EXAMPLE.js +++ b/cz-config-EXAMPLE.js @@ -67,5 +67,6 @@ module.exports = { subjectLimit: 100, // breaklineChar: '|', // It is supported for fields body and footer. // footerPrefix : 'ISSUES CLOSED:' + // addWhiteSpaceToFooterPrefix: true, // askForBreakingChangeFirst : true, // default is false }; diff --git a/spec/buildCommitSpec.js b/spec/buildCommitSpec.js index fc21ebd..41e4a80 100644 --- a/spec/buildCommitSpec.js +++ b/spec/buildCommitSpec.js @@ -98,4 +98,48 @@ line 2`; expect(buildCommit(answersNoScope, options)).toEqual(expecteMessage); }); }); + + describe('adds to footer', () => { + + it('custom footer prefix', () => { + const expectedMessage = `feat: this is a new feature\n +body + +foo bar`; + + const answers = { + type: 'feat', + subject: 'this is a new feature', + body: 'body', + footer: 'bar', + }; + + const options = { + footerPrefix: 'foo' + }; + + expect(buildCommit(answers, options)).toEqual(expectedMessage); + }); + + it('a prefix without trailing whitespace if user opts out', () => { + const expectedMessage = `feat: this is a new feature\n +body + +foobar`; + + const answers = { + type: 'feat', + subject: 'this is a new feature', + body: 'body', + footer: 'bar', + }; + + const options = { + addWhiteSpaceToFooterPrefix: false, + footerPrefix: 'foo' + }; + expect(buildCommit(answers, options)).toEqual(expectedMessage); + }); + + }) });