File size: 565 Bytes
5e21013 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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)
|