From 4b569b8c35bf098122dcde6f666fe6ee7674f864 Mon Sep 17 00:00:00 2001 From: Creabine Date: Fri, 8 Mar 2019 18:23:35 +0800 Subject: [PATCH] feat: add option to skip any questions (#65) --- README.md | 7 ++++--- cz-config-EXAMPLE.js | 2 ++ index.d.ts | 1 + questions.js | 5 +++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9ba9d05..5dd1e02 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/cz-config-EXAMPLE.js b/cz-config-EXAMPLE.js index 1dffd9f..3de9ce1 100644 --- a/cz-config-EXAMPLE.js +++ b/cz-config-EXAMPLE.js @@ -49,6 +49,8 @@ module.exports = { allowCustomScopes: true, allowBreakingChanges: ['feat', 'fix'], + // skip any questions you want + skipQuestions: ['body', 'footer'], // limit subject length subjectLimit: 100 diff --git a/index.d.ts b/index.d.ts index 5581b67..a559426 100644 --- a/index.d.ts +++ b/index.d.ts @@ -19,6 +19,7 @@ declare module "cz-customizable" { }; allowCustomScopes?: boolean; allowBreakingChanges?: string[]; + skipQuestions?: string[]; appendBranchNameToCommitMessage?: boolean; breakingPrefix?: string; footerPrefix?: string; diff --git a/questions.js b/questions.js index 10d5c25..6fda416 100644 --- a/questions.js +++ b/questions.js @@ -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):'; @@ -129,6 +130,10 @@ module.exports = { } ]; + questions = questions.filter(function(item) { + return !skipQuestions.includes(item.name); + }); + return questions; } };