在 yeoman 中导航文件夹结构

Navigating folder structure in yeoman

您好,我正在构建一个 Yeoman 生成器来创建 wordpress/grunt/bootstrap 样板。 我知道一个已经存在,但我想以一种特定的方式设置 wordpress 主题。

我的第一步是在项目目录中安装最新的 wordpress。 我用

this.composeWith('wordpress', {});

调用另一个 yeoman 生成器为我安装 wordpress。 我的问题是 wordpress 文件直接复制到根目录中。有什么方法可以让 generator-wordpress 安装在特定的子目录中吗?

我知道在设置 wordpress 生成器时有一个选项可以指定自定义文件夹结构,但我不想去那里,只是在正确的目录中调用生成器。

此致

亚历克斯

经过一些研究,似乎添加了一个选项:

https://github.com/yeoman/generator-node/pull/186/files

只有我的index.js

无法让它在这里工作
var generators = require('yeoman-generator');
var userVars ={};

module.exports = generators.Base.extend({

constructor: function () {
// Calling the super constructor is important so our generator is correctly  set up
generators.Base.apply(this, arguments);

// Next, add your custom code
this.option('coffee'); // This method adds support for a `--coffee` flag

var done = this.async();

},

  prompting: function () {
    return this.prompt([{
          type    : 'input',
          name    : 'name',
          message : 'Your project name',
          default : this.appname // Default to current folder name
    }, 

    {
          type    : 'input',
          name    : 'themeName',
          message : 'Your wordpress theme name',
          default : this.appname // Default to current folder name
    }]).then(function (answers) {
    userVars = {
        name : answers.name,
        themeName : answers.themeName,
    }
      this.log('app name', answers.name);
      this.log('theme name', answers.themeName);
     }.bind(this));
  },


  installWordpress: function() {
this.composeWith('wordpress', { options: { generateInto:'./wordpress'}});
},
 method1: function () {
   console.log();
 },
 method2: function () {
    console.log('method 2 just ran');
 }

});

generator-nodegenerator-wordpress 是不同的生成器。它们不公开相同的选项,也不以相同的方式工作。

您需要检查 wordpress 生成器提供的选项。如果他们不支持在特定目录内生成,您应该要求生成器-wordpress 维护人员添加一个选项。

核心 Yeoman 系统不提供覆盖组合生成器目标文件夹的方法。