Skip to content

Commit 7117fbe

Browse files
committed
warn when clang-format fails
1 parent e22a639 commit 7117fbe

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/format.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const baseArgs =
2727
* @param fix whether to automatically fix the format
2828
* @param files files to format
2929
*/
30-
export function format(
30+
export async function format(
3131
options: Options, files: string[] = [], fix = false): Promise<boolean> {
3232
const program = createProgram(options);
3333
const srcFiles = files.length > 0 ?
@@ -36,7 +36,16 @@ export function format(
3636
.map(sourceFile => sourceFile.fileName)
3737
.filter(f => !f.endsWith('.d.ts'));
3838

39-
return fix ? fixFormat(srcFiles) : checkFormat(srcFiles);
39+
if (fix) {
40+
return fixFormat(srcFiles);
41+
} else {
42+
const result = await checkFormat(srcFiles);
43+
if (!result) {
44+
options.logger.error(
45+
'clang-format reported errors... run `gts fix` to address.');
46+
}
47+
return result;
48+
}
4049
}
4150

4251
/**

0 commit comments

Comments
 (0)