Skip to content

Commit 0b2a7fc

Browse files
committed
chore(jest-console): replace chalk with picocolors
1 parent b848788 commit 0b2a7fc

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

packages/jest-console/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
"dependencies": {
2222
"@jest/types": "workspace:*",
2323
"@types/node": "*",
24-
"chalk": "^4.0.0",
2524
"jest-message-util": "workspace:*",
2625
"jest-util": "workspace:*",
26+
"picocolors": "^1.0.1",
2727
"slash": "^3.0.0"
2828
},
2929
"devDependencies": {

packages/jest-console/src/BufferedConsole.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import {AssertionError, strict as assert} from 'assert';
99
import {Console} from 'console';
1010
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
11-
import chalk = require('chalk');
11+
import * as pico from 'picocolors';
1212
import {ErrorWithStack, formatTime, invariant} from 'jest-util';
1313
import type {
1414
ConsoleBuffer,
@@ -116,15 +116,15 @@ export default class BufferedConsole extends Console {
116116
this._groupDepth++;
117117

118118
if (title != null || rest.length > 0) {
119-
this._log('group', chalk.bold(format(title, ...rest)));
119+
this._log('group', pico.bold(format(title, ...rest)));
120120
}
121121
}
122122

123123
override groupCollapsed(title?: string, ...rest: Array<unknown>): void {
124124
this._groupDepth++;
125125

126126
if (title != null || rest.length > 0) {
127-
this._log('groupCollapsed', chalk.bold(format(title, ...rest)));
127+
this._log('groupCollapsed', pico.bold(format(title, ...rest)));
128128
}
129129
}
130130

packages/jest-console/src/CustomConsole.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {AssertionError, strict as assert} from 'assert';
99
import {Console} from 'console';
1010
import type {WriteStream} from 'tty';
1111
import {type InspectOptions, format, formatWithOptions, inspect} from 'util';
12-
import chalk = require('chalk');
12+
import * as pico from 'picocolors';
1313
import {clearLine, formatTime} from 'jest-util';
1414
import type {LogCounters, LogMessage, LogTimers, LogType} from './types';
1515

@@ -95,15 +95,15 @@ export default class CustomConsole extends Console {
9595
this._groupDepth++;
9696

9797
if (title != null || args.length > 0) {
98-
this._log('group', chalk.bold(format(title, ...args)));
98+
this._log('group', pico.bold(format(title, ...args)));
9999
}
100100
}
101101

102102
override groupCollapsed(title?: string, ...args: Array<unknown>): void {
103103
this._groupDepth++;
104104

105105
if (title != null || args.length > 0) {
106-
this._log('groupCollapsed', chalk.bold(format(title, ...args)));
106+
this._log('groupCollapsed', pico.bold(format(title, ...args)));
107107
}
108108
}
109109

packages/jest-console/src/getConsoleOutput.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import chalk = require('chalk');
8+
import * as pico from 'picocolors';
99
import type {Config} from '@jest/types';
1010
import {
1111
type StackTraceConfig,
@@ -34,13 +34,13 @@ export default function getConsoleOutput(
3434
let noCodeFrame = true;
3535

3636
if (type === 'warn') {
37-
message = chalk.yellow(message);
38-
typeMessage = chalk.yellow(typeMessage);
37+
message = pico.yellow(message);
38+
typeMessage = pico.yellow(typeMessage);
3939
noStackTrace = globalConfig?.noStackTrace ?? false;
4040
noCodeFrame = false;
4141
} else if (type === 'error') {
42-
message = chalk.red(message);
43-
typeMessage = chalk.red(typeMessage);
42+
message = pico.red(message);
43+
typeMessage = pico.red(typeMessage);
4444
noStackTrace = globalConfig?.noStackTrace ?? false;
4545
noCodeFrame = false;
4646
}
@@ -53,8 +53,8 @@ export default function getConsoleOutput(
5353
const formattedStackTrace = formatStackTrace(origin, config, options);
5454

5555
return `${
56-
output + TITLE_INDENT + chalk.dim(typeMessage)
57-
}\n${message.trimEnd()}\n${chalk.dim(formattedStackTrace.trimEnd())}\n\n`;
56+
output + TITLE_INDENT + pico.dim(typeMessage)
57+
}\n${message.trimEnd()}\n${pico.dim(formattedStackTrace.trimEnd())}\n\n`;
5858
}, '');
5959

6060
return `${logEntries.trimEnd()}\n`;

yarn.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,9 +3040,9 @@ __metadata:
30403040
"@jest/test-utils": "workspace:*"
30413041
"@jest/types": "workspace:*"
30423042
"@types/node": "*"
3043-
chalk: ^4.0.0
30443043
jest-message-util: "workspace:*"
30453044
jest-util: "workspace:*"
3045+
picocolors: ^1.0.1
30463046
slash: ^3.0.0
30473047
languageName: unknown
30483048
linkType: soft
@@ -13016,6 +13016,7 @@ __metadata:
1301613016
"@types/graceful-fs": ^4.1.3
1301713017
"@types/node": "*"
1301813018
"@types/stack-utils": ^2.0.0
13019+
chalk: ^4.0.0
1301913020
co: ^4.6.0
1302013021
dedent: ^1.0.0
1302113022
execa: ^5.0.0
@@ -13046,12 +13047,12 @@ __metadata:
1304613047
"@jest/types": "workspace:*"
1304713048
"@types/exit": ^0.1.30
1304813049
"@types/yargs": ^17.0.8
13049-
chalk: ^4.0.0
1305013050
exit: ^0.1.2
1305113051
import-local: ^3.0.2
1305213052
jest-config: "workspace:*"
1305313053
jest-util: "workspace:*"
1305413054
jest-validate: "workspace:*"
13055+
picocolors: ^1.0.1
1305513056
yargs: ^17.3.1
1305613057
peerDependencies:
1305713058
node-notifier: ^8.0.1 || ^9.0.0 || ^10.0.0
@@ -13075,7 +13076,6 @@ __metadata:
1307513076
"@types/micromatch": ^4.0.7
1307613077
"@types/parse-json": ^4.0.0
1307713078
babel-jest: "workspace:*"
13078-
chalk: ^4.0.0
1307913079
ci-info: ^4.0.0
1308013080
deepmerge: ^4.2.2
1308113081
glob: ^10.3.10
@@ -13090,6 +13090,7 @@ __metadata:
1309013090
jest-validate: "workspace:*"
1309113091
micromatch: ^4.0.7
1309213092
parse-json: ^5.2.0
13093+
picocolors: ^1.0.1
1309313094
pretty-format: "workspace:*"
1309413095
semver: ^7.5.3
1309513096
slash: ^3.0.0

0 commit comments

Comments
 (0)