Friday, 15 March 2013

Yeoman sub generator: using answers to prompts from main generator -



Yeoman sub generator: using answers to prompts from main generator -

i have written yeoman sub generator , want access answers acquired prompts in main (parent) generator. format access answers in main generator's index.js file this.promptname. possible retrieve answers within sub generator?

this have (obviously) doesn't work:

var componentgenerator = yeoman.generators.namedbase.extend({ init: function () { if (this.wordpress) { // this.wordpress set main generator console.log('is wp'); } else { console.log('not wp'); } } }); module.exports = componentgenerator;

you need pass them options sub generator:

this.composewith('subgenerator', {options: {name: 'some-name'}});

then in sub generator:

this.option('name', {/* settings */});

see total documentation here:

composewith: http://yeoman.io/authoring/composability.html options/arguments: http://yeoman.io/authoring/user-interactions.html

yeoman yeoman-generator

No comments:

Post a Comment