I am new to node js, I want to execute a command in node js and want to display the running status of the command to the terminal and also to some log file.
// Displaying the output in terminal but I am not able to access child.stdout
const child = spawn(command,[], {
shell: true,
cwd: process.cwd(),
env: process.env,
stdio: 'inherit',
encoding: 'utf-8',
});
// Pushing the output to file but not able to do live interaction with terminal
const child = spawn(command,[], {
shell: true,
cwd: process.cwd(),
env: process.env,
stdio: 'pipe',
encoding: 'utf-8',
});
Is it possible to do both? Please help me with this?
Thanks in advance.