Merge generators with plop.js
In order to merge two generators while using plop.js, we can create this helper function:
plop.addHelper('mergeGenerator', (generator1, generator2) =>
{
plop.setGenerator(generator1 + ' + ' + generator2, {
description: '',
prompts: [].concat.apply([], [plop.getGenerator(gene
rator1).prompts, plop.getGenerator(generator2).prompts]),
actions: [].concat.apply([], [plop.getGenerator(gene
rator1).actions, plop.getGenerator(generator2).actions])
});
});
And use it like this:
plop.getHelper('mergeGenerator').call(this, 'name_of_generator_1', 'name_of_generator_2');