From 5635612b413376958b9ffbb07559369721dc5915 Mon Sep 17 00:00:00 2001 From: Stefano Pongelli Date: Thu, 12 Oct 2023 12:52:08 +0200 Subject: [PATCH] feat(logger): make file path clickable in terminal --- .../__tests__/__snapshots__/logger.spec.ts.snap | 4 ++-- packages/vite-plugin-checker/src/logger.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/vite-plugin-checker/__tests__/__snapshots__/logger.spec.ts.snap b/packages/vite-plugin-checker/__tests__/__snapshots__/logger.spec.ts.snap index 6dcbea1c..0120d612 100644 --- a/packages/vite-plugin-checker/__tests__/__snapshots__/logger.spec.ts.snap +++ b/packages/vite-plugin-checker/__tests__/__snapshots__/logger.spec.ts.snap @@ -2,7 +2,7 @@ exports[`logger > diagnosticToTerminalLog > get error 1`] = ` " ERROR(ESLint) Unexpected var, use let or const instead. - FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1 + FILE file:///Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1 1 | import { text } from './text' 2 | @@ -16,7 +16,7 @@ exports[`logger > diagnosticToTerminalLog > get error 1`] = ` exports[`logger > diagnosticToTerminalLog > get warning 1`] = ` " WARNING(ESLint) Unexpected var, use let or const instead. - FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1 + FILE file:///Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1 1 | import { text } from './text' 2 | diff --git a/packages/vite-plugin-checker/src/logger.ts b/packages/vite-plugin-checker/src/logger.ts index 60b9315c..6b05abd8 100644 --- a/packages/vite-plugin-checker/src/logger.ts +++ b/packages/vite-plugin-checker/src/logger.ts @@ -104,13 +104,14 @@ export function diagnosticToTerminalLog( const levelLabel = labelMap[d.level ?? DiagnosticLevel.Error] const fileLabel = boldBlack.bgCyanBright(' FILE ') + ' ' + const filePath = "file://" + d.id const position = d.loc ? chalk.yellow(d.loc.start.line) + ':' + chalk.yellow(d.loc.start.column) : '' return [ levelLabel + ' ' + d.message, - fileLabel + d.id + ':' + position + os.EOL, + fileLabel + filePath + ':' + position + os.EOL, d.codeFrame + os.EOL, d.conclusion, ]