gpt4 book ai didi

node.js - 使用 grun,如何同时运行三个阻塞任务?

转载 作者:搜寻专家 更新时间:2023-11-01 00:18:34 25 4
gpt4 key购买 nike

我已经使用 grunt-concurrent 成功地将 grunt-contrib-watchgrunt-nodemon 结合起来,允许我自动启动我的 node.js每当我编辑和转换我的 coffeescript 文件时。

这是我用来实现此目的的 gruntfile 的 grunt-concurrent 部分:

gruntfile.coffee

concurrent:
dev:
tasks: [
'watch'
'nodemon'
]
options:
logConcurrentOutput: true

watchnodemon 任务在同一个文件中配置,但为简洁起见已被删除。这工作正常。

现在我想在并发任务列表中添加一个 grunt-node-inspector。像这样:

concurrent:
dev:
tasks: [
'watch'
'nodemon'
'node-inspector'
]
options:
logConcurrentOutput: true

至少根据 grunt-nodemon 帮助文件,这应该是可能的,因为它作为示例用法给出:Running Nodemon Concurrently

但是这对我不起作用。而是仅开始前两个任务。

实验表明 grunt-concurrent 似乎仅限于同时运行两个任务。任何后续任务都将被忽略。我尝试了多种选择,例如:

concurrent:
dev1:[
'watch'
'nodemon'
]
dev2:[
'node-inspector'
]
options:
logConcurrentOutput: true

grunt.registerTask 'default', ['concurrent:dev1', 'concurrent:dev2']

我也曾尝试将 limit 选项设置为 3。我对此寄予厚望,所以我可能误解了如何正确应用该值:

concurrent:
dev:
limit: 3
tasks: [
'watch'
'nodemon'
'node-inspector'
]
options:
logConcurrentOutput: true

但是我无法运行我的第三个阻塞任务。

问题如何让所有三个阻塞任务同时运行?

谢谢。

最佳答案

将限制值放在选项中,像这样:

concurrent: {
tasks: ['nodemon', 'watch', 'node-inspector'],
options: {
limit: 5,
logConcurrentOutput: true
}
}

关于node.js - 使用 grun,如何同时运行三个阻塞任务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20618197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com