Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
89bc5da
Vendor chalk
jfmengels Feb 19, 2026
7b9598c
Format chalk with prettier
jfmengels Feb 20, 2026
33f2a7a
Vendor supports-color
jfmengels Feb 19, 2026
901128e
Format supports-color with prettier
jfmengels Feb 20, 2026
9df75a0
Simplify chalk to the project's usage
jfmengels Feb 20, 2026
7b714cd
Inline has-flag dependency
jfmengels Feb 20, 2026
1780c22
Simplify hasFlag
jfmengels Feb 20, 2026
e798ae3
Add -- to flags
jfmengels Feb 20, 2026
49398a4
Ignore terminatorPosition
jfmengels Feb 20, 2026
24c1222
Use includes()
jfmengels Feb 20, 2026
8467e1f
Simplify supports-color to project's usage
jfmengels Feb 20, 2026
04f7e88
Remove sniffFlags
jfmengels Feb 20, 2026
6727817
Move flagForceColor to inside _supportsColor
jfmengels Feb 20, 2026
488ca1f
Move computation for flagForceColor in else condition
jfmengels Feb 20, 2026
5942ad1
Merge flagForceColor and noFlagForceColor
jfmengels Feb 20, 2026
5d72b6c
Merge flagForceColor and forceColor
jfmengels Feb 20, 2026
c0d4825
Remove options and simplify arguments
jfmengels Feb 20, 2026
859ecb9
Require os only when necessary
jfmengels Feb 20, 2026
5a53966
Use booleans instead of numbers
jfmengels Feb 20, 2026
e86a30e
Return early
jfmengels Feb 20, 2026
3688215
Simplify branches
jfmengels Feb 20, 2026
9fc1ba2
Indicate where to find more styles
jfmengels Feb 20, 2026
249e2fb
Add flow checks for chalk
jfmengels Feb 20, 2026
09210f9
Don't check for invalid CLI flags
jfmengels Feb 21, 2026
c513665
Simplify FORCE_COLOR checks
jfmengels Feb 21, 2026
d63d47d
Check for forceColor undefined early
jfmengels Feb 21, 2026
44e73b3
Inline min
jfmengels Feb 21, 2026
b6ae380
Assume all terminals support colors
jfmengels Feb 21, 2026
8b43284
Check for tty when needed
jfmengels Feb 21, 2026
c675487
Assume all CIs support colors
jfmengels Feb 21, 2026
02a06d8
Switch branches
jfmengels Feb 21, 2026
ff53beb
Merge 2 functions
jfmengels Feb 21, 2026
80e0f4b
Switch branches
jfmengels Feb 21, 2026
5d745b6
Use return statement
jfmengels Feb 21, 2026
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
2 changes: 1 addition & 1 deletion lib/Compile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow

const { supportsColor } = require('chalk');
const { supportsColor } = require('./chalk');
const spawn = require('cross-spawn');
const ElmCompiler = require('./ElmCompiler');
const Report = require('./Report');
Expand Down
2 changes: 1 addition & 1 deletion lib/Generate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

const { supportsColor } = require('chalk');
const { supportsColor } = require('./chalk');
const fs = require('fs');
const path = require('path');
const { DependencyProvider } = require('./DependencyProvider.js');
Expand Down
2 changes: 1 addition & 1 deletion lib/RunTests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

const chalk = require('chalk');
const chalk = require('./chalk');
const chokidar = require('chokidar');
const path = require('path');
const readline = require('readline');
Expand Down
2 changes: 1 addition & 1 deletion lib/Supervisor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

const chalk = require('chalk');
const chalk = require('./chalk');
const child_process = require('child_process');
const fs = require('fs');
const net = require('net');
Expand Down
20 changes: 20 additions & 0 deletions lib/chalk.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @flow
const supportsColor = require('./supports-color');

// Find more colors/styles in
// https://github.com/chalk/ansi-styles/blob/main/index.js

function red(string /*: string */) /*: string */ {
return supportsColor ? `\x1B[31m${string}\x1B[39m` : string;
}

function blue(string /*: string */) /*: string */ {
return supportsColor ? `\x1B[34m${string}\x1B[39m` : string;
}

module.exports = {
supportsColor,

red,
blue,
};
65 changes: 65 additions & 0 deletions lib/supports-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';
/**
Based on https://github.com/chalk/supports-color v10.2.2
but adapted to use CommonJs and simplified to our needs (only knowing whether stdout supports colors).

MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const tty = require('tty');

const { env } = process;

function supportsColor() {
if ('FORCE_COLOR' in env && env.FORCE_COLOR !== '') {
return env.FORCE_COLOR !== 'false' && env.FORCE_COLOR !== '0';
}

if (process.argv.includes('--no-color')) {
return false;
} else if (process.argv.includes('--color')) {
return true;
}

// Check for Azure DevOps pipelines.
// Has to be above the tty check.
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
return true;
}

if (!tty.isatty(1)) {
return false;
}

if (process.platform === 'win32') {
return true;
}

if ('CI' in env) {
return true;
}

if (env.TERM === 'dumb') {
return false;
}

if (
'TERM' in env ||
'COLORTERM' in env ||
'TERM_PROGRAM' in env ||
'TEAMCITY_VERSION' in env
) {
return true;
}

return false;
}

module.exports = supportsColor();
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
},
"homepage": "https://github.com/rtfeldman/node-test-runner#readme",
"dependencies": {
"chalk": "^4.1.2",
"chokidar": "^3.5.3",
"commander": "^9.4.1",
"cross-spawn": "^7.0.6",
Expand Down
Loading