Ability to skip a prompt
- Dominant language
- JavaScript
- Stars
- 195
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
IMHO one of important features that `grunt-init` lacks is ability to skip a question (prompt) depending on answers for previous questions (results of previous prompts).
For example, consider the following excerpt (actually it is prompts from [grunt-init-pack](https://github.com/gamtiq/grunt-init-pack) template):
``` js
{
name: "travis",
message: "Will this project be tested with Travis CI?",
"default": "Y/n",
warning: "If selected, you must enable Travis support for this project in https://travis-ci.org/profile",
sanitize: convertYesNo
},
{
name: "travis_badge",
message: "Would you like to include Travis build status badge into README.md?",
"default": function(value, data, done) {
done(null, yesRegExp.test(data.travis) ? "Y/n" : "y/N");
},
sanitize: convertYesNo
},
```
When a user answers `no` for `travis` prompt, `travis_badge` prompt should be skipped. Unfortunately it is impossible in current version.
I propose to add support for prompt's options that will allow specifying pre-action and maybe post-action (of course they should be functions). Let’s name those actions `before` and `after`. So that when `false` value (exactly) is returned from `before` action, the corresponding prompt will be skipped.
What do you think about this?
I can make pull request if this proposal will be approved.
Contributor guide
Assessment
This issue has not been assessed yet.