preserve color when executing child_process.spawn

There are new 'stdio' option for child_process.spawn(). Try following:

spawn("path to executable", ["params"], {stdio: "inherit"});

"Inherit" means [0, 1, 2] or [process.stdin, process.stdout, process.stderr].

crossplatform solution that worked for me was to use both shell: true and stdio: 'inherit':

const spawn = require('child_process').spawn;

spawn('node', ['./child.js'], { shell: true, stdio: 'inherit' });

thanks @59naga

If you are getting error:

Cannot call method 'on' of null

Try this:

spawn("command", ["args"], { env : { FORCE_COLOR: true }});

works with mocha