cli-reporter: Remove dedent method, force callback for indent, make the behaviour of spacer the same as optionalSpacer
MODIFY
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
packages/@romejs/cli-diagnostics/DiagnosticsPrinter.ts
@@ -468,9 +468,10 @@ export default class DiagnosticsPrinter extends Error {
includeHeaderInAdvice: false,
outdated: isOutdated,
});
+
reporter.hr(derived.header);
- reporter.indent();
+ reporter.indent(() => {
// Concat all the advice together
const derivedAdvice: DiagnosticAdvice = [
...derived.advice,
@@ -490,7 +491,7 @@ export default class DiagnosticsPrinter extends Error {
reporter,
});
if (!noSpacer) {
- reporter.optionalSpacer();
+ reporter.spacer();
}
}
@@ -499,9 +500,9 @@ export default class DiagnosticsPrinter extends Error {
const {origins} = diag;
if (origins.length > 0) {
- reporter.optionalSpacer();
- reporter.info('Why are you seeing this diagnostic?');
reporter.spacer();
+ reporter.info('Why are you seeing this diagnostic?');
+ reporter.forceSpacer();
reporter.list(
origins.map(origin => {
let res = `<emphasis>${origin.category}</emphasis>`;
@@ -514,8 +515,7 @@ export default class DiagnosticsPrinter extends Error {
);
}
}
-
- reporter.dedent();
+ });
}
filterDiagnostics(): Diagnostics {

MODIFY
packages/@romejs/cli-diagnostics/printAdvice.ts
packages/@romejs/cli-diagnostics/printAdvice.ts
@@ -70,9 +70,9 @@ function printInspect(
opts: AdvicePrintOptions,
): boolean {
const {reporter} = opts;
- reporter.indent();
+ reporter.indent(() => {
reporter.inspect(item.data);
- reporter.dedent();
+ });
return false;
}
@@ -111,9 +111,9 @@ function printCode(
): boolean {
const {reporter} = opts;
const {code} = item;
- reporter.indent();
+ reporter.indent(() => {
reporter.logAll(escapeMarkup(code));
- reporter.dedent();
+ });
return false;
}
@@ -174,7 +174,7 @@ function printStacktrace(
const isFirstPart = diagnostic.advice[0] === item;
if (!isFirstPart) {
opts.reporter.info(item.title === undefined ? 'Stack trace' : item.title);
- opts.reporter.spacer();
+ opts.reporter.forceSpacer();
}
opts.reporter.processedList(
@@ -268,7 +268,7 @@ function printStacktrace(
opts,
);
if (!skipped) {
- opts.reporter.spacer();
+ opts.reporter.forceSpacer();
shownCodeFrames++;
}
}

cli-reporter: Remove dedent method, force callback for indent, make the behaviour of spacer the same as optionalSpacer