简体   繁体   English

延伸角度yeoman发电机

[英]Extending angular yeoman generator

I basically want to create a custom yeoman generator that by default extends the standard generator-angular npm package. 我基本上想要创建一个自定义的yeoman生成器,默认情况下会扩展标准的generator-angular npm包。 (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. 现在我正在做的是我通过复制所有子文件夹结构并创建几乎空的js文件来设置所有角度子生成器,以便将子生成器处理到生成器角度包。

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. Yeoman生成一个原始的JavaScript原型对象。 Just extend them like you'd do it normally with any other JavaScript object. 只需像使用任何其他JavaScript对象一样扩展它们。

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. 您可以对Generator-Angular NPM模块执行相同的操作,也可以对任何子发生器执行相同的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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