Skip to content

Commit

Permalink
Pass --no-color as is
Browse files Browse the repository at this point in the history
  • Loading branch information
kevva committed Sep 18, 2017
1 parent 6be4470 commit 889d87f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ module.exports = (file, opts, execArgv) => {

const args = [JSON.stringify(opts)];

if (hasFlag('--color') || hasFlag('--no-color')) {
if (hasFlag('--color')) {
args.push(`--color=${opts.color}`);
}

if (hasFlag('--no-color')) {
args.push(`--no-color`);
}

const ps = childProcess.fork(path.join(__dirname, 'test-worker.js'), args, {
cwd: opts.projectDir,
silent: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/test-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ globals.options = opts;
const serializeError = require('./serialize-error');

// Initialize color support
chalk.enabled = typeof opts.color === 'boolean' && opts.color;
chalk.enabled = opts.color;

(opts.require || []).forEach(require);

Expand Down
3 changes: 1 addition & 2 deletions test/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ test('color support is initialized correctly', t => {

return Promise.all([
fork(fixture('chalk-enabled.js'), {color: true}).run({}),
fork(fixture('chalk-disabled.js'), {color: false}).run({}),
fork(fixture('chalk-disabled.js'), {}).run({})
fork(fixture('chalk-disabled.js'), {color: false}).run({})
]).then(info => {
info.forEach(info => {
if (info.stats.failCount > 0) {
Expand Down

0 comments on commit 889d87f

Please sign in to comment.