jhipster - jhipster 将选项传递给蓝图
问题描述
我正在尝试创建一个 jhipster 蓝图来覆盖弹簧控制器的功能。我想访问从命令行运行的选项:
jhipster -d --blueprint generator-jhipster-baris-blueprint spring-controller policyEffectiveStatus --path 附录
这个命令使我的蓝图运行。我可以通过以下方式从代码中的参数访问名称“policyEffectiveStatus”:
this.argument('name', { type: String, required: true });
this.name = this.options.name;
但我无法访问选项路径。如何将选项传递给我的蓝图?
这是我的 index.js :
module.exports = class extends BaseGenerator {
constructor(args, opts) {
super(args, Object.assign({ fromBlueprint: true }, opts)); // fromBlueprint
variable is important
this.argument('name', { type: String, required: true });
// This adds support for a `--path` flag
this.option('path', {
desc: 'Indicates the path for class request mapping',
type: String
});
this.path = this.options['path'];
this.log(`this.path is ${this.path}`);
this.path = this.options.path;
this.log(`this.path is ${this.path}`);
this.name = this.options.name;
const jhContext = this.jhipsterContext = this.options.jhipsterContext;
this.configOptions = jhContext.configOptions || {};
if (!jhContext) {
this.error(`This is a JHipster blueprint and should be used only like ${chalk.yellow('jhipster --blueprint generator-jhipster-sample-blueprint')}`);
}
}
我正在运行的命令是:
解决方案
刚刚发现它们存在于 jhipster 上下文下的选项中,这意味着:
this.options.jhipsterContext.options
而不是这个
this.options
推荐阅读
- c++ - 以下是 gfg 中子集和问题的代码。请告诉我它有什么问题
- python - 连接熊猫数据框
- terraform - 在资源创建中使用地图列表的地图
- vba - 由于格式错误,VBA 运行时错误 13
- php - 尽管进行了数小时的故障排除并且它是一个相对简单的程序,但我似乎无法让我的帖子表单在 PHP 中正常工作
- java - 用于openge连接问题的插件sonarqube
- php - PHP将带有空格的字符串数字转换为浮点数
- php - PHPMailer 在浏览器中工作,但不能作为 cron 工作
- javascript - 为什么“事件”在不将其作为参数传递的情况下起作用?
- prolog - 将字符列表转换为字符串列表,每个字符串在 Prolog 中包含 3 个字符