Skip to content

Commit

Permalink
Extract codeRegex to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Dec 4, 2024
1 parent ecc28a2 commit 2c93b93
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/astro/src/core/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 2c93b93

Please sign in to comment.