Skip to content

Commit 0c1fe14

Browse files
markdalgleishBo Lingen
authored and
Bo Lingen
committed
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 45520e7 commit 0c1fe14

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.
@@ -63,8 +69,12 @@ module.exports = function (options) {
6369
message: 'Provide a longer description of the change:\n'
6470
}, {
6571
type: 'input',
66-
name: 'footer',
67-
message: 'List any breaking changes or issues closed by this change:\n'
72+
name: 'breaking',
73+
message: 'List any breaking changes:\n'
74+
}, {
75+
type: 'input',
76+
name: 'issues',
77+
message: 'List any issues closed by this change:\n'
6878
}
6979
]).then(function (answers) {
7080

@@ -93,7 +103,15 @@ module.exports = function (options) {
93103

94104
// Wrap these lines at 100 characters
95105
var body = wrap(answers.body, wrapOptions);
96-
var footer = wrap(answers.footer, wrapOptions);
106+
107+
// Apply breaking change prefix, removing it if already present
108+
var breaking = answers.breaking.trim();
109+
breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : '';
110+
breaking = wrap(breaking, wrapOptions);
111+
112+
var issues = wrap(answers.issues, wrapOptions);
113+
114+
var footer = filter([ breaking, issues ]).join('\n\n');
97115

98116
commit(head + '\n\n' + body + '\n\n' + footer);
99117
});

0 commit comments

Comments
 (0)