microsoft/typespec
Publicmirrored fromhttps://github.com/microsoft/typespecAvailable
eng/scripts/check-format.js
20lines · modecode
| 1 | // @ts-check |
| 2 | import { |
| 3 | ensureDotnetVersion, |
| 4 | runDotnetFormat, |
| 5 | } from "../../packages/internal-build-utils/dist/src/index.js"; |
| 6 | import { CommandFailedError, runPrettier } from "./helpers.js"; |
| 7 | |
| 8 | try { |
| 9 | runPrettier("--list-different"); |
| 10 | ensureDotnetVersion({ exitWithSuccessInDevBuilds: true }); |
| 11 | runDotnetFormat("--verify-no-changes"); |
| 12 | } catch (err) { |
| 13 | if (err instanceof CommandFailedError) { |
| 14 | console.error( |
| 15 | "\nERROR: Files above are not formatted correctly. Run `rush format` and commit the changes." |
| 16 | ); |
| 17 | process.exit(err.proc?.status ?? 1); |
| 18 | } |
| 19 | throw err; |
| 20 | } |
| 21 | |