Fix astro check
file paths not handling URL paths correctly (#3988)
* Fix `astro check` file paths not handling URLs path correctly * Add changeset
This commit is contained in:
parent
66012e334a
commit
9841c21e8e
2 changed files with 8 additions and 1 deletions
5
.changeset/breezy-llamas-behave.md
Normal file
5
.changeset/breezy-llamas-behave.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix certain characters showing incorrectly in `astro check`
|
|
@ -11,6 +11,7 @@ import {
|
||||||
white,
|
white,
|
||||||
yellow,
|
yellow,
|
||||||
} from 'kleur/colors';
|
} from 'kleur/colors';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
import stringWidth from 'string-width';
|
import stringWidth from 'string-width';
|
||||||
|
|
||||||
export function printDiagnostic(filePath: string, text: string, diag: Diagnostic): string {
|
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
|
// 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 realStartLine = diag.range.start.line + 1;
|
||||||
const realStartCharacter = diag.range.start.character + 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
|
// 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)
|
yellow(realStartCharacter)
|
||||||
)}`;
|
)}`;
|
||||||
result.push(
|
result.push(
|
||||||
|
|
Loading…
Reference in a new issue