Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix astro check file paths not handling URL paths correctly #3988

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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