Skip to content

Commit

Permalink
perf: port enhancements from main
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Sep 25, 2023
1 parent 49a52aa commit d707bb1
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions husky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ exit_hook() {
exit "$1"
}

self="$(
cd "$(dirname "$0")"
pwd -P
)"
hook="$(basename "$0")"
script="$self/../$hook"
hook="${0##*/}"
script="${0%/*/*}/../$hook"

debug "starting $hook..."

Expand All @@ -31,15 +27,15 @@ if [ "$HUSKY" = "0" ] || [ ! -f "$script" ]; then
exit 0
fi

for file in "$XDG_CONFIG_HOME/husky/init.sh" "$HOME/.config/husky/init.sh" "$HOME/.huskyrc"; do
if [ -f "$file" ]; then
for file in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc.sh";
do if [ -f "$file" ]; then
debug "sourcing $file"
. "$file"
break
fi
done

if [ "$(basename -- "$SHELL")" = "zsh" ] || [ "$(basename -- "$SHELL")" = "bash" ]; then
if [ "${SHELL##*/}" = "zsh" ]; then
debug "running $script with $SHELL"
"$SHELL" -e "$script" "$@"
else
Expand Down

0 comments on commit d707bb1

Please sign in to comment.