Skip to content

Commit 0ef0ca1

Browse files
committed
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.
1 parent fa70351 commit 0ef0ca1

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

cli.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,7 @@ function run(file) {
113113
.on('stats', stats)
114114
.on('test', test)
115115
.on('unhandledRejections', handleRejections)
116-
.on('uncaughtException', handleExceptions)
117-
.on('data', function (data) {
118-
process.stdout.write(data);
119-
});
116+
.on('uncaughtException', handleExceptions);
120117
}
121118

122119
function handleRejections(data) {

lib/fork.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ module.exports = function (args) {
1414
var file = args[0];
1515

1616
var options = {
17-
silent: true,
18-
cwd: path.dirname(file)
17+
cwd: path.dirname(file),
18+
stdio: ['ignore', process.stdout, process.stdout]
1919
};
2020

2121
var ps = childProcess.fork(filepath, args, options);
@@ -76,15 +76,6 @@ module.exports = function (args) {
7676
send(ps, 'teardown');
7777
});
7878

79-
// emit data events on forked process' output
80-
ps.stdout.on('data', function (data) {
81-
ps.emit('data', data);
82-
});
83-
84-
ps.stderr.on('data', function (data) {
85-
ps.emit('data', data);
86-
});
87-
8879
promise.on = function () {
8980
ps.on.apply(ps, arguments);
9081

0 commit comments

Comments
 (0)