| from pathlib import Path | |
| import subprocess | |
| import sys | |
| root = Path(__file__).resolve().parents[2] | |
| mode = sys.argv[1] if len(sys.argv) > 1 else "" | |
| commands = { | |
| "pre-commit": [ | |
| ["pnpm", "run", "quality:pre-commit"], | |
| ], | |
| "pre-push": [ | |
| ["pnpm", "run", "quality:pre-push"], | |
| ], | |
| } | |
| if mode not in commands: | |
| sys.stderr.write(f"Unknown quality gate: {mode}\n") | |
| raise SystemExit(2) | |
| for command in commands[mode]: | |
| result = subprocess.run(command, cwd=root) | |
| if result.returncode != 0: | |
| raise SystemExit(result.returncode) | |