pre-commit 483 B

123456789101112131415161718
  1. #!/usr/bin/env sh
  2. . "$(dirname "$0")/h"
  3. # 获取当前分支名
  4. branch_name=$(git rev-parse --abbrev-ref HEAD)
  5. echo "Current branch: $branch_name"
  6. # 检查是否在 main 或 pre 分支
  7. if [[ "$branch_name" == "main" || "$branch_name" == "pre" ]]; then
  8. echo "Running full project type check and linting for branch $branch_name..."
  9. npm run lint
  10. npm run format
  11. npm run tsc
  12. else
  13. echo "Running staged files check for branch $branch_name..."
  14. npx --no-install lint-staged
  15. fi