简单的yoman generator

本文介绍了使用YoMan创建Generator的过程及各阶段的功能划分,包括初始化、配置、文件生成等步骤,并分享了个人感想。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这两天用yoman做了两个generator

The available priorities are (in running order):

  1. initializing - Your initialization methods (checking current project state, getting configs, etc)
  2. prompting - Where you prompt users for options (where you'd call this.prompt())
  3. configuring - Saving configurations and configure the project (creating .editorconfig files and other metadata files)
  4. default - If the method name doesn't match a priority, it will be pushed to this group.
  5. writing - Where you write the generator specific files (routes, controllers, etc)
  6. conflicts - Where conflicts are handled (used internally)
  7. install - Where installation are run (npm, bower)
  8. end - Called last, cleanup, say good bye, etc

Follow these priorities guidelines and your generator will play nice with others.

以上钩子依次执行,私有方法可以'_'开头。

在prompting里做一些询问,比如工程名啊,description

在writing里写文件

在install里做npm或者yarn的安装

在end里画个退出字符画


 

昨天是个值得纪念的日子

希望以后的每一年

看到这里都会觉得很暖很开心

转载于:https://www.cnblogs.com/zqiong/p/6706799.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值