Shell
#!/bin/bash
# Pre-Commit Hook: Comprehensive Validation
# Blocks commits if quality gates fail
echo "π¦ Running pre-commit checks..."
# 1. TypeScript compilation check
echo "π Checking TypeScript compilation..."
npx tsc --noEmit
TS_EXIT=$?
if [ $TS_EXIT -ne 0 ]; then
echo "β TypeScript compilation failed - fix errors before committing"
exit 1
fi
echo "β
TypeScript check passed"
# 2. Run migration-specific tests (if they exist)
if [ -f "package.json" ] && grep -q "test:migrations" package.json; then
echo "π§ͺ Running migration tests..."
npm run test:migrations
TEST_EXIT=$?
if [ $TEST_EXIT -ne 0 ]; then
echo "β Migration tests failed - fix before committing"
exit 1
fi
echo "β
Migration tests passed"
fi
echo "β
All pre-commit checks passed - proceeding with commit"
exit 0