【问题标题】:Move yo-rc.json file to root folder将 yo-rc.json 文件移动到根文件夹
【发布时间】:2017-05-16 23:26:55
【问题描述】:

我正在使用 yeoman 创建一个生成器,但我遇到了一个小问题。

基本上我的生成器将能够创建这样的模块结构:

  • 模块名称
    • 控制器
    • nameofmodule.php

当我执行生成器时,我位于 nameofmodule 的父文件夹中(nameofmodule 文件夹由生成器创建)。

现在我想保存一个 yo-rc.json 文件来保存一些配置(作为模块名称)。

问题是我希望 yo-rc.json 文件位于 nameofmodule 文件夹中,而不是位于我启动 yeoman 生成器的文件夹中。

你知道我可以如何更改 yo-rc.json 文件路径吗?或者也许在 nameofmodule 中创建一个新的?

非常感谢

【问题讨论】:

    标签: json yeoman yeoman-generator


    【解决方案1】:

    我设法通过更改目标根路径来更改 .yo-rc.json 路径:

    this.destinationRoot(path.join(this.destinationRoot(), '/' + this.appDir));
    

    所以在我创建了我的应用程序结构后,我调用了:

    this.on('end', function () {
      this.destinationRoot(path.join(this.destinationRoot(), '/' + this.appDir));
      this.config.set('appName', this.appName);
      this.config.set('appDir', this.appDir);
      this.config.set('modules', []);
    });
    

    现在它仅适用于 Base 生成器。我不知道如何在 NamedBase 生成器中应用目标根。

    我希望这会有所帮助。

    【讨论】:

    • 太棒了,这正是我想要的 :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多