summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Erika <3019731+Princesseuh@users.noreply.github.com> 2022-07-20 11:16:22 -0400
committerGravatar GitHub <noreply@github.com> 2022-07-20 11:16:22 -0400
commit9841c21e8ecc1ed2dbf46648355871800ac0b172 (patch)
tree2cf8d1d0a53413f02cf9aeb2a6b8b502d1cded9f
parent66012e334aff6a7f9a5116d9cd3dc505711eb95b (diff)
downloadastro-9841c21e8ecc1ed2dbf46648355871800ac0b172.tar.gz
astro-9841c21e8ecc1ed2dbf46648355871800ac0b172.tar.zst
astro-9841c21e8ecc1ed2dbf46648355871800ac0b172.zip
Fix `astro check` file paths not handling URL paths correctly (#3988)
* Fix `astro check` file paths not handling URLs path correctly * Add changeset
-rw-r--r--.changeset/breezy-llamas-behave.md5
-rw-r--r--packages/astro/src/cli/check/print.ts4
2 files changed, 8 insertions, 1 deletions
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(