【问题标题】:Yeoman: How to install dependencies sequentiallyYeoman:如何按顺序安装依赖项
【发布时间】:2015-11-23 01:05:52
【问题描述】:

在我的生成器中,我想按顺序运行npm ijspm i,这样日志输出就不会混合在一起。我该怎么做?

目前,如果我把它们放在一起:

install: function() {
    this.npmInstall();
    this.spawnCommand('jspm', ['install']);
}

install: {
    npm: function() { this.npmInstall(); },
    jspm: function() { this.spawnCommand('jspm', ['install']); }
}

将同时运行。

我知道我可以jspm i 放入end 队列中,但我想将它用于安装后代码并且它有同样的问题(即所有代码都在end 队列是并行运行的)。

【问题讨论】:

    标签: generator yeoman


    【解决方案1】:

    Yeoman 只有 Node.js 和 JavaScript。您将像处理任何异步操作一样处理此问题。

    在 Yeoman 中,您使用 this.async() 来定义异步任务:

    install: {
        npm: function() {
            this.npmInstall();
        },
        jspm: function() {
            this.spawnCommand('jspm', ['install']).on('close', this.async());
        }
    }
    

    注意你也可以使用this.spawnCommandSync

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 2015-05-07
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-19
      相关资源
      最近更新 更多