You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.0 KiB
48 lines
1.0 KiB
#!/usr/bin/env sh
|
|
#
|
|
# Husky Helper Script - Conditional Activation
|
|
# This file is sourced by all Husky hooks
|
|
#
|
|
if [ -z "$husky_skip_init" ]; then
|
|
# Check if Husky is enabled for this user
|
|
if [ "$HUSKY_ENABLED" != "1" ] && [ ! -f .husky-enabled ]; then
|
|
echo "Husky is not enabled. To enable:"
|
|
echo " export HUSKY_ENABLED=1"
|
|
echo " or create .husky-enabled file"
|
|
exit 0
|
|
fi
|
|
|
|
debug () {
|
|
if [ "$HUSKY_DEBUG" = "1" ]; then
|
|
echo "husky (debug) - $1"
|
|
fi
|
|
}
|
|
|
|
readonly hook_name="$(basename -- "$0")"
|
|
debug "starting $hook_name..."
|
|
|
|
if [ "$HUSKY" = "0" ]; then
|
|
debug "HUSKY env variable is set to 0, skipping hook"
|
|
exit 0
|
|
fi
|
|
|
|
if [ -f ~/.huskyrc ]; then
|
|
debug "sourcing ~/.huskyrc"
|
|
. ~/.huskyrc
|
|
fi
|
|
|
|
readonly husky_skip_init=1
|
|
export husky_skip_init
|
|
sh -e "$0" "$@"
|
|
exitCode="$?"
|
|
|
|
if [ $exitCode != 0 ]; then
|
|
echo "husky - $hook_name hook exited with code $exitCode (error)"
|
|
fi
|
|
|
|
if [ $exitCode = 127 ]; then
|
|
echo "husky - command not found in PATH=$PATH"
|
|
fi
|
|
|
|
exit $exitCode
|
|
fi
|
|
|