Search code examples
yeomanyeoman-generator

Yeoman generator another prompt if yes


I'm making a big Yeoman generator and i wanna make something like

> Do you wanna continue?(y/n)

if yes it will continue to make a list of Choices or Question(s) if no it'll skip

do i'll be able to do like that ?


Solution

  • Inquirer.js offers a when option you can use to ignore some prompts depending on previous answers.

    Although, in your case, I think it'd be cleaner to simply separate your prompts in two methods. For example mainPrompt and _extraPrompt. Then when the mainPrompt is over, check the answer for the continue question and run - or not - the extra prompts questions.