Node.js: Capture STDOUT of `child_process.spawn`

前端 未结 3 903
-上瘾入骨i
-上瘾入骨i 2021-01-05 05:24

I need to capture in a custom stream outputs of a spawned child process.

child_process.spawn(command[, args][, options])

F

3条回答
  •  心在旅途
    2021-01-05 06:06

    You can do it without using a temporary file:

    var process = child_process.spawn(command[, args][, options]);
    process.stdout.on('data', function (chunk) {
        console.log(chunk);
    });
    

提交回复
热议问题