2013-08-04 201 views
0

我有一个咕噜任务,其中启动了socket-io服务器。保持任务咕噜任务打开

我已经找到了一种通过在其后面运行'watch'任务来保持任务'开放'(即,不在命令行上直接退出)的方法。 e.g

grunt.registerTask('default', ["mytask", "watch"]);

但是这需要我填写在Gruntfile如一些虚拟的数据。

// Not needed... 
watch: { 
    files: "test/*" 
}, 

那么有没有办法让我的任务运行,而无需使用监视任务一起呢?

由于

回答

0

这里是从http://gruntjs.com/creating-tasks示例

任务可以是异步的。

grunt.registerTask('asyncfoo', 'My "asyncfoo" task.', function() { 
    // Force task into async mode and grab a handle to the "done" function. 
    var done = this.async(); 
    // Run some sync stuff. 
    grunt.log.writeln('Processing task...'); 
    // And some async stuff. 
    setTimeout(function() { 
     grunt.log.writeln('All done!'); 
     done(); 
    }, 1000); 
}); 
0

此功能是内置到咕噜

grunt.registerTask('asyncme', 'My asynchronous task.', function() { 
    var done = this.async(); 
    doSomethingAsync(done); 
});