Use process.stdinand process.stdoutthreads.
Here is an example from these documents:
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
process.stdout.write('data: ' + chunk);
});
process.stdin.on('end', function () {
process.stdout.write('end');
});
The call process.stdin.resume()starts the data stream from standard input and will support your program until stdin stops or ends.
source
share