Skip to content

Commit 5083cb9

Browse files
committed
Improve error formatting
1 parent 8737238 commit 5083cb9

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

scripts/react-compiler-compliance-check.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import path from 'path';
1515
import CLI from './utils/CLI';
1616
import FileUtils from './utils/FileUtils';
1717
import Git from './utils/Git';
18-
import {log, error as logError, info as logInfo, success as logSuccess, warn as logWarn} from './utils/Logger';
18+
import {log, error as logError, errorDetail as logErrorDetail, info as logInfo, success as logSuccess, warn as logWarn} from './utils/Logger';
1919

2020
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
2121
const ReactCompilerConfig = require('../config/babel/reactCompilerConfig');
@@ -131,7 +131,7 @@ function printErrors(filename: string, errors: CompilerError[]): void {
131131
}
132132
for (const error of errors) {
133133
const location = formatErrorLocation(filename, error);
134-
logError(` ${location}: ${error.reason}`);
134+
logErrorDetail(`${location}: ${error.reason}`);
135135
}
136136
if (IS_CI) {
137137
console.log('::endgroup::');
@@ -157,10 +157,10 @@ function checkFiles(inputs: string[], verbose: boolean): boolean {
157157

158158
switch (result.status) {
159159
case 'compiled':
160-
logSuccess(`COMPILED ${file}`);
160+
logSuccess(`COMPILED ${file}`);
161161
break;
162162
case 'failed':
163-
logError(`FAILED ${file}`);
163+
logError(`FAILED ${file}`);
164164
printErrors(file, result.errors);
165165
hasFailure = true;
166166
break;
@@ -230,7 +230,7 @@ async function checkChangedFiles(remote: string, verbose: boolean): Promise<bool
230230

231231
if (mainStatus === 'compiled') {
232232
failures.push({file: filename, reason: 'File compiled on main but fails to compile on this branch (regression)', errors: result.errors});
233-
logError(`FAILED ${filename} (regression: compiled on main)`);
233+
logError(`FAILED ${filename} (regression: compiled on main)`);
234234
printErrors(filename, result.errors);
235235
} else if (verbose) {
236236
logWarn(`WARNING ${filename} (fails to compile, but also failed on main)`);

scripts/utils/Logger.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const error = (...args: unknown[]) => {
4949
log(...lines);
5050
};
5151

52+
const errorDetail = (...args: unknown[]) => {
53+
const lines = [` ${COLOR_RED}↳`, ...args, COLOR_RESET];
54+
log(...lines);
55+
};
56+
5257
const formatLink = (name: string | number, url: string) => `\x1b]8;;${url}\x1b\\${name}\x1b]8;;\x1b\\`;
5358

54-
export {log, info, warn, note, error, success, formatLink, bold};
59+
export {log, info, warn, note, error, errorDetail, success, formatLink, bold};

0 commit comments

Comments
 (0)