YEOMAN run multiple sub generators in one function -
i have angular based generator 3 sub generators controller directive , service. want run 1 function takes name variable/input , runs 3 of these @ same time instead of having run each 1 separately.
yeoman offers composewith()
(docs) can use invoke other (sub)generators.
'use strict'; var generators = require('yeoman-generator'); module.exports = generators.base.extend({ constructor: function () { generators.base.apply(this, arguments); this.argument('thename', { type: string, required: true }); }, initializing: function() { this.composewith('my-generator:mysubgen1', { args: [this.thename] }); this.composewith('my-generator:mysubgen2', { args: [this.thename] }); } });
in example above assume generator named my-generator
, has 2 subgenerators (mysubgen1
, mysubgen2
).
the code above go third subgenerator, e.g. doall
. if call $ yo my-generator:doall foobar
run both of composed sub-generators, passing foobar
first argument.
Comments
Post a Comment