The code snippet shown below works great for obtaining access to the stdout of a system command. Is there some way that I can modify this code so as to also get access to t
You may also use child_process.spawnSync(), as it returns much more:
return:
pid Pid of the child process
output Array of results from stdio output
stdout | The contents of output[1]
stderr | The contents of output[2]
status The exit code of the child process
signal The signal used to kill the child process
error The error object if the child process failed or timed out
So the exit code you're looking for would be ret.status.