我成功地将grunt-contrib-watch与使用grunt-concurrent的grunt-nodemon组合在一起,允许我在编辑和传输coffeescript文件时自动启动node.js实例。
下面是我用来实现这一目标的gruntfile的grunt-concurrent部分:
gruntfile.coffee
concurrent:
dev:
tasks: [
'watch'
'nodemon'
]
options:
logConcurrentOutput: truewatch和nodemon任务是在同一个文件中配置的,但为了简洁起见已经删除了。这个很好用。
现在,我想在并发任务列表中添加一个grunt-node-inspector。就像这样:
concurrent:
dev:
tasks: [
'watch'
'nodemon'
'node-inspector'
]
options:
logConcurrentOutput: true至少根据grunt-nodemon帮助文件,这应该是可能的,因为它是一个示例用法:并发运行Nodemon
不过,这对我不起作用。相反,只启动前两个任务。
实验表明,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但是我不能让我的第三个阻塞任务运行。
问题如何使三个阻塞任务同时运行?
谢谢。
发布于 2014-01-04 22:59:48
将限值放入选项中,如下所示:
concurrent: {
tasks: ['nodemon', 'watch', 'node-inspector'],
options: {
limit: 5,
logConcurrentOutput: true
}
}发布于 2013-12-19 07:06:51
我一直在使用grunt.util.spawn来运行我的任务,并包括最后的1阻塞调用。http://gruntjs.com/api/grunt.util#grunt.util.spawn 事件
这个街区杀死了孩子们。
var children = [];
process.on('SIGINT', function(){
children.forEach(function(child) {
console.log('killing child!');
child.kill('SIGINT');
});
});
module.exports = function (grunt) {
'use strict';..。
然后我注册一个任务
grunt.registerTask('blocked', 'blocking calls', function() {
var path = require('path')
var bootstrapDir = path.resolve(process.cwd()) + '/bootstrap';
var curDir = path.resolve(process.cwd());
children.push(
grunt.util.spawn( {
cmd: 'grunt',
args: ['watch'],
opts: {
cwd: bootstrapDir,
stdio: 'inherit',
}
})
);
children.push(
grunt.util.spawn( {
cmd: 'grunt',
args: ['nodemon'],
opts: {
cwd: curDir,
stdio: 'inherit',
}
})
);
children.push(
grunt.util.spawn( {
cmd: 'grunt',
args: ['node-inspector'],
opts: {
cwd: curDir,
stdio: 'inherit',
}
})
);
grunt.task.run('watch');
});在这种情况下,您可以将当前的工作dir更改为gruntfile.js并运行多个实例。
https://stackoverflow.com/questions/20618197
复制相似问题