Grunt产生的进程不捕获输出
我已经使用Grunt产生了一个进程,但没有写入输出stream(例如console.log
)的东西正在控制台中显示。
我想Grunt显示过程的任何输出。
grunt.util.spawn( { cmd: 'node' , args: ['app.js'] , opts: { stdio: [ process.stdin , process.stout , process.stderr ] } })
尝试将其设置为opts: {stdio: 'inherit'}
。 否则,你可以pipe输出:
var child = grunt.util.spawn({ cmd: process.argv[0], // <- A better way to find the node binary args: ['app.js'] }); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr);
或者如果你想修改输出:
child.stdout.on('data', function(buf) { console.log(String(buf)); });