Skip to content

Commit d09161a

Browse files
authored
Remove the faking of the TTY in worker processes
* Remove the faking of the TTY in worker processes * Replace global console in workers with one that has color mode enabled (if the main process has colors enabled, that is).
1 parent 465aef2 commit d09161a

File tree

14 files changed

+26
-286
lines changed

14 files changed

+26
-286
lines changed

lib/fork.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ if (fs.realpathSync(__filename) !== __filename) {
1212
// the presence of this variable allows it to require this one instead
1313
const AVA_PATH = path.resolve(__dirname, '..');
1414

15-
const describeTTY = tty => ({
16-
colorDepth: tty.getColorDepth ? tty.getColorDepth() : undefined,
17-
hasColors: typeof tty.hasColors === 'function',
18-
columns: tty.columns || 80,
19-
rows: tty.rows
20-
});
21-
2215
const workerPath = require.resolve('./worker/subprocess');
2316

2417
module.exports = (file, opts, execArgv) => {
@@ -34,10 +27,6 @@ module.exports = (file, opts, execArgv) => {
3427
opts = {
3528
file,
3629
baseDir: process.cwd(),
37-
tty: {
38-
stderr: process.stderr.isTTY ? describeTTY(process.stderr) : false,
39-
stdout: process.stdout.isTTY ? describeTTY(process.stdout) : false
40-
},
4130
...opts
4231
};
4332

lib/worker/fake-tty-has-colors.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/worker/fake-tty.js

Lines changed: 0 additions & 94 deletions
This file was deleted.

lib/worker/subprocess.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
'use strict';
2+
const {Console} = require('console'); // eslint-disable-line node/prefer-global/console
23
const currentlyUnhandled = require('currently-unhandled')();
34

45
require('./ensure-forked'); // eslint-disable-line import/no-unassigned-import
@@ -9,7 +10,11 @@ ipc.send({type: 'ready-for-options'});
910
ipc.options.then(options => {
1011
require('./options').set(options);
1112
require('../chalk').set(options.chalkOptions);
12-
require('./fake-tty'); // eslint-disable-line import/no-unassigned-import
13+
14+
if (options.chalkOptions.level > 0) {
15+
const {stdout, stderr} = process;
16+
global.console = new Console({stdout, stderr, colorMode: true});
17+
}
1318

1419
const babelManager = require('../babel-manager');
1520
const nowAndTimers = require('../now-and-timers');

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
],
5959
"dependencies": {
6060
"@concordance/react": "^2.0.0",
61-
"ansi-escapes": "^4.3.0",
6261
"ansi-styles": "^4.2.1",
6362
"arrify": "^2.0.1",
6463
"chalk": "^3.0.0",
@@ -113,6 +112,7 @@
113112
"devDependencies": {
114113
"@ava/babel": "^0.5.0",
115114
"@types/node": "^10.17.13",
115+
"ansi-escapes": "^4.3.0",
116116
"delay": "^4.3.0",
117117
"esm": "^3.2.25",
118118
"execa": "^4.0.0",

test/fixture/tty/callbacks.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

test/fixture/tty/color-disabled.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/fixture/tty/color-enabled.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/fixture/tty/get-color-depth-missing.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)