Skip to content

Commit

Permalink
Fix astro check file paths not handling URL paths correctly (#3988)
Browse files Browse the repository at this point in the history
* Fix `astro check` file paths not handling URLs path correctly

* Add changeset
  • Loading branch information
Princesseuh authored Jul 20, 2022
1 parent 66012e3 commit 9841c21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/breezy-llamas-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix certain characters showing incorrectly in `astro check`
4 changes: 3 additions & 1 deletion packages/astro/src/cli/check/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
white,
yellow,
} from 'kleur/colors';
import { fileURLToPath } from 'url';
import stringWidth from 'string-width';

export function printDiagnostic(filePath: string, text: string, diag: Diagnostic): string {
Expand All @@ -19,9 +20,10 @@ export function printDiagnostic(filePath: string, text: string, diag: Diagnostic
// Lines and characters are 0-indexed, so we need to add 1 to the offset to get the actual line and character
const realStartLine = diag.range.start.line + 1;
const realStartCharacter = diag.range.start.character + 1;
const normalizedFilePath = fileURLToPath(new URL(filePath, 'file://'));

// IDE friendly path that user can CTRL+Click to open the file at a specific line / character
const IDEFilePath = `${bold(cyan(filePath))}:${bold(yellow(realStartLine))}:${bold(
const IDEFilePath = `${bold(cyan(normalizedFilePath))}:${bold(yellow(realStartLine))}:${bold(
yellow(realStartCharacter)
)}`;
result.push(
Expand Down

0 comments on commit 9841c21

Please sign in to comment.