Skip to content

Commit

Permalink
feat: add option to skip any questions (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Creabine authored and leonardoanalista committed Mar 8, 2019
1 parent 67e3ab7 commit 4b569b8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ Here are the options you can set in your `.cz-config.js`:
}
```
* allowCustomScopes: {boolean, default false}: adds the option `custom` to scope selection so you can still type a scope if you need.
* allowBreakingChanges: {Array of Strings: default none}. List of commit types you would like to the question `breaking change` prompted. Eg.: ['feat', 'fix']
* allowBreakingChanges: {Array of Strings: default none}. List of commit types you would like to the question `breaking change` prompted. Eg.: ['feat', 'fix'].
* skipQuestions: {Array of Strings: default none}. List of questions you want to skip. Eg.: ['body', 'footer'].
* appendBranchNameToCommitMessage: If you use `cz-customizable` with `cz-customizable-ghooks`, you can get the branch name automatically appended to the commit message. This is done by a commit hook on `cz-customizable-ghooks`. This option has been added on `cz-customizable-ghooks`, v1.3.0. Default value is `true`.
* breakingPrefix: {string, default 'BREAKING CHANGE:'}: Set a custom prefix for the breaking change block in commit messages
* footerPrefix: {string, default 'ISSUES CLOSED:'}: Set a custom prefix for the footer block in commit messages
* breakingPrefix: {string, default 'BREAKING CHANGE:'}: Set a custom prefix for the breaking change block in commit messages.
* footerPrefix: {string, default 'ISSUES CLOSED:'}: Set a custom prefix for the footer block in commit messages.

## Related tools
- (https://github.com/commitizen/cz-cli)
Expand Down
2 changes: 2 additions & 0 deletions cz-config-EXAMPLE.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module.exports = {

allowCustomScopes: true,
allowBreakingChanges: ['feat', 'fix'],
// skip any questions you want
skipQuestions: ['body', 'footer'],

// limit subject length
subjectLimit: 100
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare module "cz-customizable" {
};
allowCustomScopes?: boolean;
allowBreakingChanges?: string[];
skipQuestions?: string[];
appendBranchNameToCommitMessage?: boolean;
breakingPrefix?: string;
footerPrefix?: string;
Expand Down
5 changes: 5 additions & 0 deletions questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
// normalize config optional options
var scopeOverrides = config.scopeOverrides || {};
var messages = config.messages || {};
var skipQuestions = config.skipQuestions || [];

messages.type = messages.type || 'Select the type of change that you\'re committing:';
messages.scope = messages.scope || '\nDenote the SCOPE of this change (optional):';
Expand Down Expand Up @@ -129,6 +130,10 @@ module.exports = {
}
];

questions = questions.filter(function(item) {
return !skipQuestions.includes(item.name);
});

return questions;
}
};

0 comments on commit 4b569b8

Please sign in to comment.