From 9841c21e8ecc1ed2dbf46648355871800ac0b172 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:16:22 -0400 Subject: [PATCH] Fix `astro check` file paths not handling URL paths correctly (#3988) * Fix `astro check` file paths not handling URLs path correctly * Add changeset --- .changeset/breezy-llamas-behave.md | 5 +++++ packages/astro/src/cli/check/print.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/breezy-llamas-behave.md diff --git a/.changeset/breezy-llamas-behave.md b/.changeset/breezy-llamas-behave.md new file mode 100644 index 000000000..ca0cc3e54 --- /dev/null +++ b/.changeset/breezy-llamas-behave.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix certain characters showing incorrectly in `astro check` diff --git a/packages/astro/src/cli/check/print.ts b/packages/astro/src/cli/check/print.ts index 26866c051..5c40f785e 100644 --- a/packages/astro/src/cli/check/print.ts +++ b/packages/astro/src/cli/check/print.ts @@ -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 { @@ -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(