Skip to content

Commit a07daeb

Browse files
committed
Initialize Chalk in worker processes with same level as main process
1 parent 4fdd416 commit a07daeb

File tree

9 files changed

+10
-10
lines changed

9 files changed

+10
-10
lines changed

lib/cli.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ exports.run = async () => { // eslint-disable-line complexity
167167
}
168168
}
169169

170-
const chalk = require('./chalk').set({level: combined.color === false ? 0 : require('chalk').level});
170+
const chalkOptions = {level: combined.color === false ? 0 : require('chalk').level};
171+
const chalk = require('./chalk').set(chalkOptions);
171172

172173
if (confError) {
173174
if (confError.parent) {
@@ -312,7 +313,7 @@ exports.run = async () => { // eslint-disable-line complexity
312313
const api = new Api({
313314
babelProvider,
314315
cacheEnabled: combined.cache !== false,
315-
color: combined.color,
316+
chalkOptions,
316317
concurrency: combined.concurrency || 0,
317318
debug,
318319
experiments,

lib/fork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = (file, opts, execArgv) => {
5151
...opts
5252
};
5353

54-
const args = [opts.color ? '--color' : '--no-color'].concat(opts.workerArgv);
54+
const args = [opts.chalkOptions.level === 0 ? '--no-color' : '--color'].concat(opts.workerArgv);
5555

5656
const subprocess = childProcess.fork(workerPath, args, {
5757
cwd: opts.projectDir,

lib/worker/load-chalk.js

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

lib/worker/subprocess.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const currentlyUnhandled = require('currently-unhandled')();
33

44
/* eslint-disable import/no-unassigned-import */
55
require('./ensure-forked');
6-
require('./load-chalk');
76
require('./consume-argv');
87
/* eslint-enable import/no-unassigned-import */
98

@@ -12,6 +11,7 @@ const ipc = require('./ipc');
1211
ipc.send({type: 'ready-for-options'});
1312
ipc.options.then(options => {
1413
require('./options').set(options);
14+
require('../chalk').set(options.chalkOptions);
1515
require('./fake-tty'); // eslint-disable-line import/no-unassigned-import
1616

1717
const babelManager = require('../babel-manager');

test/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function apiCreator(options = {}) {
1717
options.babelProvider = babelManager({projectDir: options.projectDir}).main({config: options.babelConfig});
1818
}
1919

20+
options.chalkOptions = {level: 0};
2021
options.concurrency = 2;
2122
options.extensions = options.extensions || ['js'];
2223
options.experiments = {};

test/assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
require('../lib/chalk').set();
3-
require('../lib/worker/options').set({color: false});
3+
require('../lib/worker/options').set({chalkOptions: {level: 0}});
44

55
const path = require('path');
66
const stripAnsi = require('strip-ansi');

test/helper/report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const run = (type, reporter, match = []) => {
8989
concurrency: 1,
9090
updateSnapshots: false,
9191
snapshotDir: false,
92-
color: true
92+
chalkOptions: {level: 1}
9393
};
9494
let pattern = '*.js';
9595

test/test-try-commit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
require('../lib/chalk').set();
3-
require('../lib/worker/options').set({color: false});
3+
require('../lib/worker/options').set({chalkOptions: {level: 0}});
44

55
const {test} = require('tap');
66
const delay = require('delay');

test/try-snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
require('../lib/chalk').set();
3-
require('../lib/worker/options').set({color: false});
3+
require('../lib/worker/options').set({chalkOptions: {level: 0}});
44

55
const path = require('path');
66
const {test} = require('tap');

0 commit comments

Comments
 (0)