husky.sh 717 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env sh
  2. if [ -z "$husky_skip_init" ]; then
  3. debug () {
  4. if [ "$HUSKY_DEBUG" = "1" ]; then
  5. echo "husky (debug) - $1"
  6. fi
  7. }
  8. readonly hook_name="$(basename -- "$0")"
  9. debug "starting $hook_name..."
  10. if [ "$HUSKY" = "0" ]; then
  11. debug "HUSKY env variable is set to 0, skipping hook"
  12. exit 0
  13. fi
  14. if [ -f ~/.huskyrc ]; then
  15. debug "sourcing ~/.huskyrc"
  16. . ~/.huskyrc
  17. fi
  18. readonly husky_skip_init=1
  19. export husky_skip_init
  20. sh -e "$0" "$@"
  21. exitCode="$?"
  22. if [ $exitCode != 0 ]; then
  23. echo "husky - $hook_name hook exited with code $exitCode (error)"
  24. fi
  25. if [ $exitCode = 127 ]; then
  26. echo "husky - command not found in PATH=$PATH"
  27. fi
  28. exit $exitCode
  29. fi