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