Skip to content

Commit

Permalink
feat(additionalQuestion): support additional questions for commit (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
parveen14 authored Dec 23, 2024
1 parent 987ace4 commit 7b08c70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ Here are the options you can set in your `.cz-config.js`:
]
}
```
* **additionalQuestions**:{Array of object} To ask additional question. Answers will be appended to body part. All keys of object are required.
```
additionalQuestions: [
{
type: 'input',
name: 'time',
message: 'Time spent (i.e. 1h 15m) (optional):\n',
mapping: "#time"
},
{
type: 'input',
name: 'comment',
message: 'Jira comment (optional):\n',
mapping: "#comment"
}
],
```
* **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'].
* **skipQuestions**: {Array of Strings: default none}. List of questions you want to skip. Eg.: ['body', 'footer'].
Expand Down Expand Up @@ -201,4 +218,4 @@ my items are:



Leonardo Correa
Leonardo Correa
6 changes: 6 additions & 0 deletions lib/build-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ module.exports = (answers, config) => {
body = '';
}

(config.additionalQuestions || []).forEach((question) => {
if (answers[question.name]) {
body += `\n${question.mapping} ${answers[question.name]}`;
}
});

const breaking = wrap(answers.breaking, wrapOptions);
const footer = wrap(answers.footer, wrapOptions);

Expand Down
1 change: 1 addition & 0 deletions lib/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ module.exports = {
message: messages.body,
default: config.usePreparedCommit && getPreparedCommit('body'),
},
...(config.additionalQuestions || []),
{
type: 'input',
name: 'breaking',
Expand Down

0 comments on commit 7b08c70

Please sign in to comment.