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: optionally append whitespace to footer prefix #168

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion buildCommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
1 change: 1 addition & 0 deletions cz-config-EXAMPLE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
44 changes: 44 additions & 0 deletions spec/buildCommitSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

})
});