Skip to content

Pass --no-color flag down to the forked process - fixes #843 #1104

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
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ exports.run = function () {
' --source, -S Pattern to match source files so tests can be re-run (Can be repeated)',
' --timeout, -T Set global timeout',
' --concurrency, -c Maximum number of test files running at the same time (EXPERIMENTAL)',
' --no-color Disable color output',
'',
'Examples',
' ava',
Expand Down
5 changes: 0 additions & 5 deletions lib/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ var repeating = require('repeating');
var objectAssign = require('object-assign');
var colors = require('../colors');

chalk.enabled = true;
Object.keys(colors).forEach(function (key) {
colors[key].enabled = true;
});

function MiniReporter(options) {
if (!(this instanceof MiniReporter)) {
return new MiniReporter(options);
Expand Down
4 changes: 0 additions & 4 deletions lib/reporters/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ var plur = require('plur');
var repeating = require('repeating');
var colors = require('../colors');

Object.keys(colors).forEach(function (key) {
colors[key].enabled = true;
});

function VerboseReporter() {
if (!(this instanceof VerboseReporter)) {
return new VerboseReporter();
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ $ ava --help
--source, -S Pattern to match source files so tests can be re-run (Can be repeated)
--timeout, -T Set global timeout
--concurrency, -c Maximum number of test files running at the same time (EXPERIMENTAL)
--no-color Disable color output

Examples
ava
Expand Down
7 changes: 5 additions & 2 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var test = require('tap').test;
global.Promise = require('bluebird');
var getStream = require('get-stream');
var figures = require('figures');
var arrify = require('arrify');
var chalk = require('chalk');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need arrify because Array.prototype.concat already can concat single values
Array.prototype.concat docs

var mkdirp = require('mkdirp');
var touch = require('touch');
Expand All @@ -21,6 +20,10 @@ var cliPath = path.join(__dirname, '../cli.js');
chalk.enabled = true;
var colors = require('../lib/colors');

Object.keys(colors).forEach(function (key) {
colors[key].enabled = true;
});

Copy link
Author

@thinkimlazy thinkimlazy Nov 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to turn on colors no matter what while testing. Also in case that Istanbul turning them off at this condition

function execCli(args, opts, cb) {
var dirname;
var env;
Expand All @@ -43,7 +46,7 @@ function execCli(args, opts, cb) {
var stderr;

var processPromise = new Promise(function (resolve) {
child = childProcess.spawn(process.execPath, [path.relative(dirname, cliPath)].concat(arrify(args)), {
child = childProcess.spawn(process.execPath, [path.relative(dirname, cliPath)].concat(args, '--color'), {
Copy link
Author

@thinkimlazy thinkimlazy Nov 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Force to use colors while testing
And get rid of useless arrify

cwd: dirname,
env: env,
stdio: [null, 'pipe', 'pipe']
Expand Down
3 changes: 3 additions & 0 deletions test/reporters/mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ var colors = require('../../lib/colors');
var compareLineOutput = require('../helper/compare-line-output');

chalk.enabled = true;
Object.keys(colors).forEach(function (key) {
colors[key].enabled = true;
});

var graySpinner = chalk.gray.dim(process.platform === 'win32' ? '-' : '⠋');

Expand Down
3 changes: 3 additions & 0 deletions test/reporters/verbose.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var verboseReporter = require('../../lib/reporters/verbose');
var compareLineOutput = require('../helper/compare-line-output');

chalk.enabled = true;
Object.keys(colors).forEach(function (key) {
colors[key].enabled = true;
});

// tap doesn't emulate a tty environment and thus process.stdout.columns is
// undefined. Expect an 80 character wide line to be rendered.
Expand Down