Socket.io 保持任务grunt任务处于打开状态

Socket.io 保持任务grunt任务处于打开状态,socket.io,gruntjs,grunt-contrib-watch,Socket.io,Gruntjs,Grunt Contrib Watch,我有一个繁重的任务,启动socket io服务器和其他东西 我找到了一种保持任务“打开”(即不直接在命令行上退出)的方法,即在任务之后立即运行“监视”任务。e、 g grunt.registerTask('default',[“mytask”,“watch”]) 但这需要我在GrunFile中填写一些虚拟数据,例如 // Not needed... watch: { files: "test/*" }, 那么,有没有一种方法可以让我的任务保持运行,而不必同时使用watch任务呢 谢谢此功能

我有一个繁重的任务,启动socket io服务器和其他东西

我找到了一种保持任务“打开”(即不直接在命令行上退出)的方法,即在任务之后立即运行“监视”任务。e、 g

grunt.registerTask('default',[“mytask”,“watch”])

但这需要我在GrunFile中填写一些虚拟数据,例如

// Not needed...
watch: {
  files: "test/*"
},
那么,有没有一种方法可以让我的任务保持运行,而不必同时使用watch任务呢


谢谢

此功能内置于grunt中

grunt.registerTask('asyncme', 'My asynchronous task.', function() {
   var done = this.async();
   doSomethingAsync(done);
});
这里有一个来自中国的例子

任务可以是异步的

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);
});