Fix Reporter#table padding
MODIFY
packages/@romejs/cli-reporter/Reporter.ts
packages/@romejs/cli-reporter/Reporter.ts
@@ -808,10 +808,14 @@ export default class Reporter {
}));
}
+ for (const stream of this.getStreams(false)) {
// Get column widths
const cols: Array<number> = [];
for (let i = 0; i < head.length; i++) {
- const widths = rows.map((row): number => stripAnsi(row[i]).length);
+ const widths = rows.map((row): number => this.markupifyLength(
+ stream,
+ row[i],
+ ));
cols[i] = Math.max(...widths);
}
@@ -819,14 +823,14 @@ export default class Reporter {
const builtRows = rows.map((row): string => {
for (let i = 0; i < row.length; i++) {
const field = row[i];
- const padding = cols[i] - stripAnsi(field).length;
-
+ const padding = cols[i] - this.markupifyLength(stream, field);
row[i] = field + ' '.repeat(padding);
}
return row.join(' ');
});
- this.logAll(builtRows.join('\n'));
+ this.logOne(stream, builtRows.join('\n'));
+ }
}
verboseInspect(val: unknown) {
@@ -994,6 +998,17 @@ export default class Reporter {
return stripMarkupTags(str, this.markupOptions);
}
+ markupifyLength(stream: ReporterStream, str: string): number {
+ const markup = this.markupify(stream, str);
+
+ if (stream.format === 'ansi') {
+ return stripAnsi(markup).length;
+ }
+
+ // TODO html
+ return markup.length;
+ }
+
markupify(stream: ReporterStream, str: string): string {
if (stream.format === 'ansi') {
return markupToAnsi(str, this.markupOptions);

Fix Reporter#table padding