diff --git a/packages/svelte-check/package.json b/packages/svelte-check/package.json index 1d31c4cee..88b48481b 100644 --- a/packages/svelte-check/package.json +++ b/packages/svelte-check/package.json @@ -19,7 +19,7 @@ }, "homepage": "https://github.com/sveltejs/language-tools#readme", "dependencies": { - "chalk": "^4.0.0", + "picocolors": "^1.0.0", "chokidar": "^3.4.1", "fast-glob": "^3.2.7", "import-fresh": "^3.2.1", diff --git a/packages/svelte-check/rollup.config.js b/packages/svelte-check/rollup.config.js index e6c06b282..b6894df92 100644 --- a/packages/svelte-check/rollup.config.js +++ b/packages/svelte-check/rollup.config.js @@ -57,7 +57,7 @@ export default [ ...builtins, // svelte-check dependencies that are system-dependent and should // be installed as dependencies through npm - 'chalk', + 'picocolors', 'chokidar', // Dependencies of svelte-language-server // we don't want to bundle and instead require them as dependencies diff --git a/packages/svelte-check/src/writers.ts b/packages/svelte-check/src/writers.ts index 8281aff1a..dd28fcedb 100644 --- a/packages/svelte-check/src/writers.ts +++ b/packages/svelte-check/src/writers.ts @@ -1,4 +1,4 @@ -import chalk from 'chalk'; +import pc from 'picocolors'; import { sep } from 'path'; import { Writable } from 'stream'; import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol'; @@ -54,7 +54,7 @@ export class HumanFriendlyWriter implements Writer { const { line, character } = diagnostic.range.start; // eslint-disable-next-line max-len this.stream.write( - `${workspaceDir}${sep}${chalk.green(filename)}:${line + 1}:${character + 1}\n` + `${workspaceDir}${sep}${pc.green(filename)}:${line + 1}:${character + 1}\n` ); // Show some context around diagnostic range @@ -65,17 +65,17 @@ export class HumanFriendlyWriter implements Writer { let msg; if (this.isVerbose) { - msg = `${diagnostic.message} ${source}\n${chalk.cyan(code)}`; + msg = `${diagnostic.message} ${source}\n${pc.cyan(code)}`; } else { msg = `${diagnostic.message} ${source}`; } if (diagnostic.severity === DiagnosticSeverity.Error) { - this.stream.write(`${chalk.red('Error')}: ${msg}\n`); + this.stream.write(`${pc.red('Error')}: ${msg}\n`); } else if (diagnostic.severity === DiagnosticSeverity.Warning) { - this.stream.write(`${chalk.yellow('Warn')}: ${msg}\n`); + this.stream.write(`${pc.yellow('Warn')}: ${msg}\n`); } else { - this.stream.write(`${chalk.gray('Hint')}: ${msg}\n`); + this.stream.write(`${pc.gray('Hint')}: ${msg}\n`); } this.stream.write('\n'); @@ -89,7 +89,7 @@ export class HumanFriendlyWriter implements Writer { offsetAt({ line: diagnostic.range.start.line, character: 0 }, text), startOffset ); - const codeHighlight = chalk.magenta(text.substring(startOffset, endOffset)); + const codeHighlight = pc.magenta(text.substring(startOffset, endOffset)); const codePost = text.substring( endOffset, offsetAt({ line: diagnostic.range.end.line, character: Number.MAX_SAFE_INTEGER }, text) @@ -113,13 +113,13 @@ export class HumanFriendlyWriter implements Writer { `${hintCount} ${hintCount === 1 ? 'hint' : 'hints'}\n` ].join(''); if (errorCount !== 0) { - this.stream.write(chalk.red(message)); + this.stream.write(pc.red(message)); } else if (warningCount !== 0) { - this.stream.write(chalk.yellow(message)); + this.stream.write(pc.yellow(message)); } else if (hintCount !== 0) { - this.stream.write(chalk.grey(message)); + this.stream.write(pc.gray(message)); } else { - this.stream.write(chalk.green(message)); + this.stream.write(pc.green(message)); } if (this.isWatchMode) { this.stream.write('Watching for file changes...'); diff --git a/yarn.lock b/yarn.lock index 230476841..061e7df3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2060,6 +2060,11 @@ periscopic@^2.0.2: estree-walker "^1.0.0" is-reference "^1.1.4" +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + picomatch@^2.0.4: version "2.2.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a"