Skip to content

Commit

Permalink
Pipe forked IO streams instead of forwarding data events.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamestalmage committed Nov 27, 2015
1 parent fa70351 commit 0ef0ca1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
5 changes: 1 addition & 4 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 2 additions & 11 deletions lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 0ef0ca1

Please sign in to comment.