Skip to content

Commit 2022da8

Browse files
authored
(chore) replace chalk with picocolors (#1312)
For svelte-check Closes #1299
1 parent 4d299d8 commit 2022da8

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

packages/svelte-check/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"homepage": "https://github.com/sveltejs/language-tools#readme",
2121
"dependencies": {
22-
"chalk": "^4.0.0",
22+
"picocolors": "^1.0.0",
2323
"chokidar": "^3.4.1",
2424
"fast-glob": "^3.2.7",
2525
"import-fresh": "^3.2.1",

packages/svelte-check/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default [
5757
...builtins,
5858
// svelte-check dependencies that are system-dependent and should
5959
// be installed as dependencies through npm
60-
'chalk',
60+
'picocolors',
6161
'chokidar',
6262
// Dependencies of svelte-language-server
6363
// we don't want to bundle and instead require them as dependencies

packages/svelte-check/src/writers.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chalk from 'chalk';
1+
import pc from 'picocolors';
22
import { sep } from 'path';
33
import { Writable } from 'stream';
44
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol';
@@ -54,7 +54,7 @@ export class HumanFriendlyWriter implements Writer {
5454
const { line, character } = diagnostic.range.start;
5555
// eslint-disable-next-line max-len
5656
this.stream.write(
57-
`${workspaceDir}${sep}${chalk.green(filename)}:${line + 1}:${character + 1}\n`
57+
`${workspaceDir}${sep}${pc.green(filename)}:${line + 1}:${character + 1}\n`
5858
);
5959

6060
// Show some context around diagnostic range
@@ -65,17 +65,17 @@ export class HumanFriendlyWriter implements Writer {
6565

6666
let msg;
6767
if (this.isVerbose) {
68-
msg = `${diagnostic.message} ${source}\n${chalk.cyan(code)}`;
68+
msg = `${diagnostic.message} ${source}\n${pc.cyan(code)}`;
6969
} else {
7070
msg = `${diagnostic.message} ${source}`;
7171
}
7272

7373
if (diagnostic.severity === DiagnosticSeverity.Error) {
74-
this.stream.write(`${chalk.red('Error')}: ${msg}\n`);
74+
this.stream.write(`${pc.red('Error')}: ${msg}\n`);
7575
} else if (diagnostic.severity === DiagnosticSeverity.Warning) {
76-
this.stream.write(`${chalk.yellow('Warn')}: ${msg}\n`);
76+
this.stream.write(`${pc.yellow('Warn')}: ${msg}\n`);
7777
} else {
78-
this.stream.write(`${chalk.gray('Hint')}: ${msg}\n`);
78+
this.stream.write(`${pc.gray('Hint')}: ${msg}\n`);
7979
}
8080

8181
this.stream.write('\n');
@@ -89,7 +89,7 @@ export class HumanFriendlyWriter implements Writer {
8989
offsetAt({ line: diagnostic.range.start.line, character: 0 }, text),
9090
startOffset
9191
);
92-
const codeHighlight = chalk.magenta(text.substring(startOffset, endOffset));
92+
const codeHighlight = pc.magenta(text.substring(startOffset, endOffset));
9393
const codePost = text.substring(
9494
endOffset,
9595
offsetAt({ line: diagnostic.range.end.line, character: Number.MAX_SAFE_INTEGER }, text)
@@ -113,13 +113,13 @@ export class HumanFriendlyWriter implements Writer {
113113
`${hintCount} ${hintCount === 1 ? 'hint' : 'hints'}\n`
114114
].join('');
115115
if (errorCount !== 0) {
116-
this.stream.write(chalk.red(message));
116+
this.stream.write(pc.red(message));
117117
} else if (warningCount !== 0) {
118-
this.stream.write(chalk.yellow(message));
118+
this.stream.write(pc.yellow(message));
119119
} else if (hintCount !== 0) {
120-
this.stream.write(chalk.grey(message));
120+
this.stream.write(pc.gray(message));
121121
} else {
122-
this.stream.write(chalk.green(message));
122+
this.stream.write(pc.green(message));
123123
}
124124
if (this.isWatchMode) {
125125
this.stream.write('Watching for file changes...');

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,11 @@ periscopic@^2.0.2:
20602060
estree-walker "^1.0.0"
20612061
is-reference "^1.1.4"
20622062

2063+
picocolors@^1.0.0:
2064+
version "1.0.0"
2065+
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
2066+
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==
2067+
20632068
picomatch@^2.0.4:
20642069
version "2.2.1"
20652070
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"

0 commit comments

Comments
 (0)