(files: string[])
| 17 | * @returns a status code indicating whether the formatting run was successful. |
| 18 | */ |
| 19 | export async function formatFiles(files: string[]): Promise<1 | 0> { |
| 20 | // Whether any files failed to format. |
| 21 | let failures = await runFormatterInParallel(files, 'format'); |
| 22 | |
| 23 | if (failures === false) { |
| 24 | Log.info('No files matched for formatting.'); |
| 25 | return 0; |
| 26 | } |
| 27 | |
| 28 | // The process should exit as a failure if any of the files failed to format. |
| 29 | if (failures.length !== 0) { |
| 30 | Log.error(`The following files could not be formatted:`); |
| 31 | failures.forEach(({filePath, message}) => { |
| 32 | Log.info(` • ${filePath}: ${message}`); |
| 33 | }); |
| 34 | Log.error(`Formatting failed, see errors above for more information.`); |
| 35 | return 1; |
| 36 | } |
| 37 | Log.info(green(`✔ Formatting complete.`)); |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Check provided files for formatting correctness. |
no test coverage detected