I am building a yeoman generator, and need to assign an additional value/answer when a prompt is answered.
I have found a way to prompt user with another question, but what I need is to assign a predefined answer automatically in the background - so user wont see it happening, not ask the user another question. Here's an example below. Also need to do this for a list of 12+ values so the 'when' command below isn't ideal as I would have to have the when statement 12+ times
this.prompt([{
type: 'list',
name: 'redWhite',
message: 'what colour',
choices: ['red', 'white', 'blue', 'black', 'green', 'yellow', 'purple', 'cyan', 'magenta', 'brown']
}, {
when: 'redWhite.red',
type: 'confirm',
name: 'blue',
message: 'Red is nice, but how about blue instead?'
},
/*So instead of prompting user again, just need to assign a predefined value here
, {
when: 'redWhite.red',
answer: redFooBar
}, */
{
when: 'redWhite.white',
type: 'confirm',
name: 'green',
message: 'White is nice, but how about green instead?'
}, {
name: 'otherColors',
message: 'What other colors do you like?'
}], function (answer) {
// answer = {
// redWhite: 'red',
// blue: false,
// green: false,
// otherColors: 'pink, purple-ish'
// };
});