From 2c93b93b89e29386861a396882d39dd15eba117b Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Thu, 5 Dec 2024 00:12:56 +0100 Subject: [PATCH] Extract codeRegex to top level --- packages/astro/src/core/messages.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/astro/src/core/messages.ts b/packages/astro/src/core/messages.ts index 8189c8a02dec..209fbdabacb7 100644 --- a/packages/astro/src/core/messages.ts +++ b/packages/astro/src/core/messages.ts @@ -231,11 +231,13 @@ function getNetworkLogging(host: string | boolean): 'none' | 'host-to-expose' | } } +const codeRegex = /`([^`]+)`/g; + export function formatConfigErrorMessage(err: ZodError) { const errorList = err.issues.map((issue) => `! ${renderErrorMarkdown(issue.message, 'cli')}` // Make text wrapped in backticks blue. - .replaceAll(/`([^`]+)`/g, cyan('$1')) + .replaceAll(codeRegex, cyan('$1')) .split('\n') // Dim all lines in an issue except for the first which should be red. .map((line, index) => (index > 0 ? dim(line) : red(line)))