When developing a Yeoman generator, the necessary dependencies can be found at https://github.com/sboudrias/mem-fs-editor#copytplfrom-to-context-settings and https://github.com/SBoudrias/Inquirer.js/.
The main goal is to prompt the user with a question and repeat it as needed. For instance, if the user chooses to add more details, the answer will be recorded. If the response is 'no' or blank, the prompt should stop.
Subsequently, all answers should be stored in an array that can be passed to another function for listing out responses. Take a look at the current code:
askForTest1: function () {
if (this.type == 'foundation5') {
var cb = this.async();
var prompts = {
type: 'input',
name: 'test1',
message: chalk.yellow(' What is your favorite movie'),
default: 'Star Wars!'
};
this.prompt(prompts, function (props) {
this.templatedata.test1 = props.test1;
cb();
}.bind(this));
}
},
Following the prompts, there is a copyTpl object that assigns options for creating templates. This is the intended output I am aiming for within the same index.js file:
this.fs.copyTpl(
this.templatePath('/index2.html'),
this.destinationPath('app/index2.html'),
{ title: [this.templatedata.test1-a, this.templatedata.test1-b, this.templatedata.test1-c, ...], h1: this.applicationName }
);
Ultimately, the template code mentioned should yield the following result:
usingThis would generate:
using foo1
using foo2
Is this achievable? How should I approach implementing this functionality?