Skip to content

Commit 2d78e1d

Browse files
markdalgleishjimthedev
authored andcommitted
feat(adapter): Split breaking changes into separate question (commitizen#44)
BREAKING CHANGE: Breaking changes now automatically include the "BREAKING CHANGE: " prefix. closes commitizen#17
1 parent 042eadc commit 2d78e1d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

engine.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ var map = require('lodash.map');
55
var longest = require('longest');
66
var rightPad = require('right-pad');
77

8+
var filter = function(array) {
9+
return array.filter(function(x) {
10+
return x;
11+
});
12+
};
13+
814
// This can be any kind of SystemJS compatible module.
915
// We use Commonjs here, but ES6 or AMD would do just
1016
// fine.
@@ -62,8 +68,12 @@ module.exports = function (options) {
6268
message: 'Provide a longer description of the change:\n'
6369
}, {
6470
type: 'input',
65-
name: 'footer',
66-
message: 'List any breaking changes or issues closed by this change:\n'
71+
name: 'breaking',
72+
message: 'List any breaking changes:\n'
73+
}, {
74+
type: 'input',
75+
name: 'issues',
76+
message: 'List any issues closed by this change:\n'
6777
}
6878
]).then(function(answers) {
6979

@@ -85,7 +95,15 @@ module.exports = function (options) {
8595

8696
// Wrap these lines at 100 characters
8797
var body = wrap(answers.body, wrapOptions);
88-
var footer = wrap(answers.footer, wrapOptions);
98+
99+
// Apply breaking change prefix, removing it if already present
100+
var breaking = answers.breaking.trim();
101+
breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : '';
102+
breaking = wrap(breaking, wrapOptions);
103+
104+
var issues = wrap(answers.issues, wrapOptions);
105+
106+
var footer = filter([ breaking, issues ]).join('\n\n');
89107

90108
commit(head + '\n\n' + body + '\n\n' + footer);
91109
});

0 commit comments

Comments
 (0)