【问题标题】:Grunt concurrent task outputting nothingGrunt并发任务不输出任何内容
【发布时间】:2013-11-07 12:21:42
【问题描述】:

我希望我的基于 Grunt 的设置同时运行“测试”(即单元测试)和“服务器”(即 Web 服务器),这样我就可以通过 grunt testAndServer 运行两者(和更改任何文件时都更新)在同一个终端中。

代码(大部分基于yo angular脚手架):

// in initConfig:
concurrent: {
  testAndWebServer: [
    'karma',
    'watch'
  ]
},

以后

grunt.registerTask('testAndServer', function (target) {
  if (target === 'dist') {
    return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
  }

  grunt.task.run([
    'clean:server',
    'concurrent:server',
    'autoprefixer',
    'compass',
    'connect:livereload',
    'open',
    'concurrent:testAndWebServer'
  ]);
});

这确实有效,但我在终端 (PowerShell) 窗口中没有得到任何输出。我希望业力任务显示测试结果。我怎样才能做到这一点?

我在 Windows 7 的四核机器上运行 Node.js v0.10.20。

【问题讨论】:

  • 很好奇,为什么需要它们并发运行?
  • @limelights 因为我不想在单独的 cmd.exe 终端中运行测试和服务器,所以我希望它们在同一个终端中运行。
  • 我刚刚做了一个重大修改:任务实际执行,并响应文件更改,但是它们不会在终端窗口中输出任何内容。这对测试任务不利,因为我想看到那个输出。

标签: node.js gruntjs grunt-contrib-watch


【解决方案1】:

我刚刚意识到我错过了logConcurrentOutput 选项。

这使它工作:

  testAndWebServer: {
    tasks: ['watch', 'karma'],
    options: { logConcurrentOutput: true }
  },

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-01
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    • 2019-06-08
    • 1970-01-01
    相关资源
    最近更新 更多