0

你可以在 yeoman 中配置其他安装命令,超出它可以在你的自生成器上运行的标准(bower,npm)吗?

4

1 回答 1

2

您可以完全控制您编写的生成器,因此没有什么可以阻止您执行任何您想要的命令,包括其他安装工具。

如果您查看其中的install.js文件,yeoman-generator您会发现runInstall (由 和 运行installDependenciesbowerInstall只是npmInstall组合了一些随后由 执行的参数this.spawnCommand

var args = ['install'].concat(paths).concat(dargs(options));

this.spawnCommand(installer, args, cb)
  .on('error', cb)
  .on('exit', this.emit.bind(this, installer + 'Install:end', paths))
  .on('exit', function (err) {
    if (err === 127) {
      this.log.error('Could not find ' + installer + '. Please install with ' +
                          '`npm install -g ' + installer + '`.');
    }
    cb(err);
  }.bind(this));

来源

如果你想运行一个自定义工具来安装依赖项,你可以在你自己的生成器中定义一个这样的函数。

于 2013-09-02T12:02:23.793 回答