Skip to content

Commit

Permalink
warn when clang-format fails
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Oct 14, 2017
1 parent e22a639 commit 7117fbe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const baseArgs =
* @param fix whether to automatically fix the format
* @param files files to format
*/
export function format(
export async function format(
options: Options, files: string[] = [], fix = false): Promise<boolean> {
const program = createProgram(options);
const srcFiles = files.length > 0 ?
Expand All @@ -36,7 +36,16 @@ export function format(
.map(sourceFile => sourceFile.fileName)
.filter(f => !f.endsWith('.d.ts'));

return fix ? fixFormat(srcFiles) : checkFormat(srcFiles);
if (fix) {
return fixFormat(srcFiles);
} else {
const result = await checkFormat(srcFiles);
if (!result) {
options.logger.error(
'clang-format reported errors... run `gts fix` to address.');
}
return result;
}
}

/**
Expand Down

0 comments on commit 7117fbe

Please # to comment.