fix(coverage): Make output table markdown compatible (#29533)

This changes the format of the table outputted by `deno coverage` to be
markdown compatible.

Related #29532 
Closes #29465
This commit is contained in:
Boye Lillejord-Nygård 2025-06-24 11:27:07 +02:00 committed by GitHub
parent fd352537ce
commit 5b65313d48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 52 additions and 80 deletions

View file

@ -161,7 +161,7 @@ impl SummaryCoverageReporter {
};
println!(
" {file_name} | {branch_percent} | {line_percent} |",
"| {file_name} | {branch_percent} | {line_percent} |",
file_name = file_name,
branch_percent = branch_percent,
line_percent = line_percent,
@ -192,17 +192,19 @@ impl CoverageReporter for SummaryCoverageReporter {
.max("All files".len());
let header =
format!("{node:node_max$} | Branch % | Line % |", node = "File");
let separator = "-".repeat(header.len());
println!("{}", separator);
format!("| {node:node_max$} | Branch % | Line % |", node = "File");
let separator = format!(
"| {} | {} | {} |",
"-".repeat(node_max),
"-".repeat(8),
"-".repeat(6)
);
println!("{}", header);
println!("{}", separator);
entries.iter().for_each(|(node, stats)| {
self.print_coverage_line(node, node_max, stats);
});
println!("{}", separator);
self.print_coverage_line("All files", node_max, root_stats);
println!("{}", separator);
}
}