From 0ef0ca14fcf4e4e586f4157dc4838f47ca86c205 Mon Sep 17 00:00:00 2001 From: James Talmage Date: Thu, 26 Nov 2015 22:09:20 -0500 Subject: [PATCH] Pipe forked IO streams instead of forwarding `data` events. This passes terminal width information to, and enables ansi-color support in, the forked process. It makes the output of `time-require` much prettier when used in a fork. --- cli.js | 5 +---- lib/fork.js | 13 ++----------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/cli.js b/cli.js index b13782214..331cb08d3 100755 --- a/cli.js +++ b/cli.js @@ -113,10 +113,7 @@ function run(file) { .on('stats', stats) .on('test', test) .on('unhandledRejections', handleRejections) - .on('uncaughtException', handleExceptions) - .on('data', function (data) { - process.stdout.write(data); - }); + .on('uncaughtException', handleExceptions); } function handleRejections(data) { diff --git a/lib/fork.js b/lib/fork.js index dcca99725..100da35a3 100644 --- a/lib/fork.js +++ b/lib/fork.js @@ -14,8 +14,8 @@ module.exports = function (args) { var file = args[0]; var options = { - silent: true, - cwd: path.dirname(file) + cwd: path.dirname(file), + stdio: ['ignore', process.stdout, process.stdout] }; var ps = childProcess.fork(filepath, args, options); @@ -76,15 +76,6 @@ module.exports = function (args) { send(ps, 'teardown'); }); - // emit data events on forked process' output - ps.stdout.on('data', function (data) { - ps.emit('data', data); - }); - - ps.stderr.on('data', function (data) { - ps.emit('data', data); - }); - promise.on = function () { ps.on.apply(ps, arguments);