From aa3d41314843c7bcc51c9dcc37296c3e56d74fa6 Mon Sep 17 00:00:00 2001 From: jaceechan <519689794@qq.com> Date: Fri, 6 Sep 2024 01:40:47 +0800 Subject: [PATCH] feat: advance typescript teminal consolelog text color (#393) * feat: advance typescript teminal consolelog text color * fix: ensure errorCount * fix: sort import statements --- .../vite-plugin-checker/src/checkers/typescript/main.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/vite-plugin-checker/src/checkers/typescript/main.ts b/packages/vite-plugin-checker/src/checkers/typescript/main.ts index da37addd..2133c667 100644 --- a/packages/vite-plugin-checker/src/checkers/typescript/main.ts +++ b/packages/vite-plugin-checker/src/checkers/typescript/main.ts @@ -2,6 +2,7 @@ import os from 'node:os' import path from 'node:path' import { fileURLToPath } from 'node:url' import { parentPort } from 'node:worker_threads' +import chalk from 'chalk' import invariant from 'tiny-invariant' import ts from 'typescript' @@ -107,13 +108,16 @@ const createDiagnostic: CreateDiagnostic<'typescript'> = (pluginConfig) => { } if (terminal) { + const color = errorCount && errorCount > 0 ? 'red' : 'green' consoleLog( - logChunk + + chalk[color]( + logChunk + os.EOL + wrapCheckerSummary( 'TypeScript', diagnostic.messageText.toString(), - ), + ) + ), ) } })