forked from typicode/husky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
husky.sh
44 lines (36 loc) · 931 Bytes
/
husky.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env sh
if [ -z "$husky_skip_init" ]; then
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
for file in "$XDG_CONFIG_HOME/husky/init.sh" "$HOME/.config/husky/init.sh" "$HOME/.huskyrc.sh"; do
if [ -f "$file" ]; then
debug "sourcing $file"
. "$file"
break
fi
done
readonly husky_skip_init=1
export husky_skip_init
if [ "$(basename -- "$SHELL")" = "zsh" ]; then
zsh --emulate sh -e "$0" "$@"
else
sh -e "$0" "$@"
fi
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