Skip to content
Shell
828 B
Raw Blame
#!/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