Skip to content

Commit 5635612

Browse files
author
Stefano Pongelli
committed
feat(logger): make file path clickable in terminal
1 parent ed9c093 commit 5635612

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/vite-plugin-checker/__tests__/__snapshots__/logger.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`logger > diagnosticToTerminalLog > get error 1`] = `
44
" ERROR(ESLint) Unexpected var, use let or const instead.
5-
FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1
5+
FILE file:///Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1
66

77
1 | import { text } from './text'
88
2 |
@@ -16,7 +16,7 @@ exports[`logger > diagnosticToTerminalLog > get error 1`] = `
1616

1717
exports[`logger > diagnosticToTerminalLog > get warning 1`] = `
1818
" WARNING(ESLint) Unexpected var, use let or const instead.
19-
FILE /Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1
19+
FILE file:///Users/vite-plugin-checker/playground/eslint/src/main.ts:3:1
2020

2121
1 | import { text } from './text'
2222
2 |

packages/vite-plugin-checker/src/logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,14 @@ export function diagnosticToTerminalLog(
104104

105105
const levelLabel = labelMap[d.level ?? DiagnosticLevel.Error]
106106
const fileLabel = boldBlack.bgCyanBright(' FILE ') + ' '
107+
const filePath = "file://" + d.id
107108
const position = d.loc
108109
? chalk.yellow(d.loc.start.line) + ':' + chalk.yellow(d.loc.start.column)
109110
: ''
110111

111112
return [
112113
levelLabel + ' ' + d.message,
113-
fileLabel + d.id + ':' + position + os.EOL,
114+
fileLabel + filePath + ':' + position + os.EOL,
114115
d.codeFrame + os.EOL,
115116
d.conclusion,
116117
]

0 commit comments

Comments
 (0)