简体   繁体   English

如何覆盖yeoman发电机?

[英]how to override yeoman generators?

I am trying to find a way how can I edit the default generators of generator-angular. 我试图找到一种方法如何编辑generator-angular的默认生成器。 In rails I can edit or create new generators here I am trying to create a scaffold like generator . 在rails我可以在这里编辑或创建新的生成器我正在尝试创建一个像生成器一样的脚手架。

I want to edit this. 我想编辑这个。

 yo angular:controller user

it is generating : 它正在产生:

app/scripts/controllers/user.js:
angular.module('myMod').controller('UserCtrl', function ($scope) {

// ... }); // ...});

Is there any way I can create my own sub command like : 有什么办法可以创建我自己的子命令,如:

 yo angular:scaffold user 

which should generate views + route + controller I like yoman but I am unable to find this . 应该生成视图+路由+控制器我喜欢yoman但我无法找到它。

You can use the routes generator to create scaffold it is not a pure scaffold but for that you can edit the generators first you can use this command : 您可以使用路由生成器来创建脚手架,它不是纯粹的脚手架,但为此您可以先编辑生成器,然后使用此命令:

yo angular:route myroute

This will generate : 这将产生:

app/scripts/controllers/myroute.js

 angular.module('myMod').controller('MyrouteCtrl', function ($scope) {
 // ...
});

app/views/myroute.html

If you want to customize the view file you can go to node_modules global file yo can find it here : 如果要自定义视图文件,可以转到node_modules全局文件,您可以在此处找到它:

/usr/lib/node_modules/generator-angular

And you will see a list of files you can see it here : https://github.com/yeoman/generator-angular 您将在此处看到可以看到的文件列表: https//github.com/yeoman/generator-angular

here you need to change the file called : 在这里你需要更改名为的文件:

/templates/common/app/views/view.html

here you can add you custom materials for you site and if you want to edit the controller for that you need to go to : 在这里,您可以为您的网站添加自定义材料,如果您想编辑控制器,您需要访问:

generator-angular/route/index.js

here you can edit how your generator behave , you can see this for more info how to edit or create yeoman generator. 在这里,您可以编辑生成器的行为方式,您可以在此处查看更多信息,了解如何编辑或创建自动生成器。

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

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