Skip to content
Merged
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
11 changes: 8 additions & 3 deletions apps/oxfmt/test/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,23 @@ function normalizeOutput(output: string, cwd: string): string {
// Replace absolute paths
.replace(new RegExp(RegExp.escape(cwdPath), "g"), "<cwd>")
.replace(new RegExp(RegExp.escape(rootPath), "g"), "<cwd>")
// NOTE: These redundant processes are necessary to obtain stable snapshots in CI.
// In Oxfmt, there are 2 kinds of errors displayed
// - on the Rust side using `miette`
// - on the JS side by `prettier`
// and in order to handle them in one place, it needs to be done outside of Oxfmt.
// Strip ANSI escape codes (e.g. from Prettier error messages)
// eslint-disable-next-line no-control-regex
// oxlint-disable-next-line no-control-regex
.replace(/\x1b\[[0-9;]*m/g, "")
// Normalize miette Unicode theme to ASCII
// Normalize `miette` Unicode theme to ASCII
.replace(/×/g, "x")
.replace(/╭/g, ",")
.replace(/─/g, "-")
.replace(/│/g, "|")
.replace(/·/g, ":")
.replace(/┬/g, "|")
.replace(/╰/g, "`")
// Trim trailing whitespace per line
// Trim trailing whitespace per line for sure
.replace(/[^\S\n]+$/gm, "")
);
}
Expand Down
Loading