Skip to content

Commit

Permalink
feat(logger): make file path clickable in terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Pongelli committed Oct 12, 2023
1 parent ed9c093 commit eda4c4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down
3 changes: 2 additions & 1 deletion packages/vite-plugin-checker/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down

0 comments on commit eda4c4e

Please sign in to comment.