Skip to content

Do not clobber forked process color level. #1713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@ const path = require('path');
const fs = require('fs');
const Promise = require('bluebird');
const debug = require('debug')('ava');
const supportsColor = require('supports-color');
const AvaError = require('./ava-error');

const colorLevels = {
0: 'false',
1: 'true',
2: '256',
3: '16m'
};
const currentColorLevel = colorLevels[supportsColor.level];

if (fs.realpathSync(__filename) !== __filename) {
console.warn('WARNING: `npm link ava` and the `--preserve-symlink` flag are incompatible. We have detected that AVA is linked via `npm link`, and that you are using either an early version of Node 6, or the `--preserve-symlink` flag. This breaks AVA. You should upgrade to Node 6.2.0+, avoid the `--preserve-symlink` flag, or avoid using `npm link ava`.');
}
Expand Down Expand Up @@ -34,7 +43,8 @@ module.exports = (file, opts, execArgv) => {
} : false
}, opts);

const args = [JSON.stringify(opts), opts.color ? '--color' : '--no-color'].concat(opts.workerArgv);
const colorArg = opts.color ? `--color=${currentColorLevel}` : '--no-color';
const args = [JSON.stringify(opts), colorArg].concat(opts.workerArgv);

const ps = childProcess.fork(path.join(__dirname, 'test-worker.js'), args, {
cwd: opts.projectDir,
Expand Down