您可以创建一个别名任务,使用这些节点标志生成 grunt,如下所示:
grunt.registerTask('debug', function() {
var done = this.async();
// Specify tasks to run spawned
var tasks = Array.prototype.slice.call(arguments, 0);
grunt.util.spawn({
// Use the existing node path
cmd: process.execPath,
// Add the flags and use process.argv[1] to get path to grunt bin
args: ['--debug', '--harmony', process.argv[1]].concat(tasks),
// Print everything this process is doing to the parent stdio
opts: { stdio: 'inherit' }
}, done);
});
然后你可以启动服务器并运行测试:grunt default debug:test
或者真的是任何组合:
grunt server test
(在没有节点标志的情况下运行)
grunt debug:server:test
(使用节点标志运行两者)。