Skip to content

Commit

Permalink
feat(prompt): add confirmation fields + edit for clarity (#58)
Browse files Browse the repository at this point in the history
* chore(config): switch czConfig to config

* 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 #52

* fix(engine): remove unhandled Promise rejection handler

This was for debugging and should not have been committed.

* refactor: clean up grammar and punctuation
  • Loading branch information
jlengstorf authored and jimthedev committed Oct 27, 2017
1 parent f7a770e commit d40ac2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
28 changes: 22 additions & 6 deletions engine.js
Expand Up @@ -57,23 +57,39 @@ module.exports = function (options) {
}, {
type: 'input',
name: 'scope',
message: 'Denote the scope of this change ($location, $browser, $compile, etc.):\n'
message: 'What is the scope of this change (e.g. component or file name)? (press enter to skip)\n'
}, {
type: 'input',
name: 'subject',
message: 'Write a short, imperative tense description of the change:\n'
}, {
type: 'input',
name: 'body',
message: 'Provide a longer description of the change:\n'
message: 'Provide a longer description of the change: (press enter to skip)\n'
}, {
type: 'confirm',
name: 'isBreaking',
message: 'Are there any breaking changes?',
default: false
}, {
type: 'input',
name: 'breaking',
message: 'List any breaking changes:\n'
message: 'Describe the breaking changes:\n',
when: function(answers) {
return answers.isBreaking;
}
}, {
type: 'confirm',
name: 'isIssueAffected',
message: 'Does this change affect any open issues?',
default: false
}, {
type: 'input',
name: 'issues',
message: 'List any issues closed by this change:\n'
message: 'Add issue references (e.g. "fix #123", "re #123".):\n',
when: function(answers) {
return answers.isIssueAffected;
}
}
]).then(function(answers) {

Expand All @@ -97,11 +113,11 @@ module.exports = function (options) {
var body = wrap(answers.body, wrapOptions);

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

var issues = wrap(answers.issues, wrapOptions);
var issues = answers.issues ? wrap(answers.issues, wrapOptions) : '';

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

Expand Down
6 changes: 4 additions & 2 deletions package.json
Expand Up @@ -26,7 +26,9 @@
"commitizen": "2.9.6",
"semantic-release": "^6.3.2"
},
"czConfig": {
"path": "./"
"config": {
"commitizen" : {
"path": "./index.js"
}
}
}

0 comments on commit d40ac2c

Please sign in to comment.