Skip to content

Commit 9f037c6

Browse files
committed
feat(prompts): add confirm and clarify language
Breaking changes and issues now have confirm fields to ensure answers like "no" and "n/a" don’t accidentally create breaking changes. Updated language around scopes to be less confusing for non-Angular devs. Added examples for issue references/closing. fix commitizen#52
1 parent 2291318 commit 9f037c6

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

engine.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ var filter = function(array) {
1111
});
1212
};
1313

14+
process.on('unhandledRejection', error => {
15+
console.log('unhandledRejection', error);
16+
});
17+
1418
// This can be any kind of SystemJS compatible module.
1519
// We use Commonjs here, but ES6 or AMD would do just
1620
// fine.
@@ -57,7 +61,7 @@ module.exports = function (options) {
5761
}, {
5862
type: 'input',
5963
name: 'scope',
60-
message: 'Denote the scope of this change ($location, $browser, $compile, etc.):\n'
64+
message: 'What is the scope of this change (e.g. component or file name):\n'
6165
}, {
6266
type: 'input',
6367
name: 'subject',
@@ -66,14 +70,30 @@ module.exports = function (options) {
6670
type: 'input',
6771
name: 'body',
6872
message: 'Provide a longer description of the change:\n'
73+
}, {
74+
type: 'confirm',
75+
name: 'isBreaking',
76+
message: 'Are there any breaking changes?',
77+
default: false
6978
}, {
7079
type: 'input',
7180
name: 'breaking',
72-
message: 'List any breaking changes:\n'
81+
message: 'List breaking changes (one per line):\n',
82+
when: function(answers) {
83+
return answers.isBreaking;
84+
}
85+
}, {
86+
type: 'confirm',
87+
name: 'isIssueAffected',
88+
message: 'Does this change affect any open issues?',
89+
default: false
7390
}, {
7491
type: 'input',
7592
name: 'issues',
76-
message: 'List any issues closed by this change:\n'
93+
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
94+
when: function(answers) {
95+
return answers.isIssueAffected;
96+
}
7797
}
7898
]).then(function(answers) {
7999

@@ -97,11 +117,11 @@ module.exports = function (options) {
97117
var body = wrap(answers.body, wrapOptions);
98118

99119
// Apply breaking change prefix, removing it if already present
100-
var breaking = answers.breaking.trim();
120+
var breaking = answers.breaking ? answers.breaking.trim() : '';
101121
breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : '';
102122
breaking = wrap(breaking, wrapOptions);
103123

104-
var issues = wrap(answers.issues, wrapOptions);
124+
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : '';
105125

106126
var footer = filter([ breaking, issues ]).join('\n\n');
107127

0 commit comments

Comments
 (0)