Skip to content

Commit 7af3c16

Browse files
committed
feat(adapter): Split breaking changes into separate question
BREAKING CHANGE: Breaking changes now automatically include the "" prefix. closes commitizen#17
1 parent 7025425 commit 7af3c16

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

engine.js

Lines changed: 22 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,16 @@ 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 breakingPrefix = 'BREAKING CHANGE: ';
101+
var breaking = answers.breaking.trim();
102+
breaking = breaking ? breakingPrefix + breaking.replace(breakingPrefix, '') : '';
103+
breaking = wrap(breaking, wrapOptions);
104+
105+
var issues = wrap(answers.issues, wrapOptions);
106+
107+
var footer = filter([ breaking, issues ]).join('\n\n');
89108

90109
commit(head + '\n\n' + body + '\n\n' + footer);
91110
});

0 commit comments

Comments
 (0)