jhipster 将选项传递给蓝图
jhipster passing options to blueprint
我正在尝试创建一个 jhipster 蓝图来覆盖 spring-控制器的功能。我想从命令行访问选项 运行ning :
jhipster -d --blueprint generator-jhipster-baris-blueprint spring-controller policyEffectiveStatus --path addendum
此命令制作了我的蓝图 运行。我可以通过以下方式从代码中的参数访问名称 "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')}`);
}
}
我运行ning 的命令是:
command
刚刚发现它们存在于jhipster上下文下的选项中,意思是:
this.options.jhipsterContext.options
而不是这个
this.options
我正在尝试创建一个 jhipster 蓝图来覆盖 spring-控制器的功能。我想从命令行访问选项 运行ning :
jhipster -d --blueprint generator-jhipster-baris-blueprint spring-controller policyEffectiveStatus --path addendum
此命令制作了我的蓝图 运行。我可以通过以下方式从代码中的参数访问名称 "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')}`);
}
}
我运行ning 的命令是:
command
刚刚发现它们存在于jhipster上下文下的选项中,意思是:
this.options.jhipsterContext.options
而不是这个
this.options