简体   繁体   中英

Extending angular yeoman generator

I basically want to create a custom yeoman generator that by default extends the standard generator-angular npm package. (by extending I mean giving access to all its sub generators)

Right now what I'm doing is that I have set up all angular sub generators by replicating all the subfolders structure and creating almost-empty js files to just handle the sub generator to the generator-angular package.

I wonder if there is a better way to do it, like specifying sub generator classes somewhere in the code or in a configuration file.

Yeoman generator a raw JavaScript prototyped object. Just extend them like you'd do it normally with any other JavaScript object.

var util = require('util'); // standard Node.js lib
var BaseGenerator = require('./base/generator');

function AngGenerator() {
    BaseGenerator.apply( this, arguments );
}
util.inherit( AppGenerator, BaseGenerator );

You can do the same with the Generator-Angular NPM module, and the same with any sub-generator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM