-
Notifications
You must be signed in to change notification settings - Fork 220
/
hook.tmpl
51 lines (45 loc) · 1.5 KB
/
hook.tmpl
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
45
46
47
48
49
50
51
#!/bin/sh
if [ "$LEFTHOOK" = "0" ]; then
exit 0
fi
if [ -t 1 ] ; then
exec < /dev/tty ; # <- enables interactive shell
fi
call_lefthook()
{
dir="$(git rev-parse --show-toplevel)"
osArch=$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')
cpuArch=$(echo "$(uname -m)" | sed 's/aarch64/arm64/')
if lefthook{{.Extension}} -h >/dev/null 2>&1
then
eval lefthook{{.Extension}} $@
{{if .Extension -}}
{{/* Check if lefthook.bat exists. Ruby bundler creates such a wrapper */ -}}
elif lefthook.bat -h >/dev/null 2>&1
then
eval lefthook.bat $@
{{end -}}
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook{{.Extension}}"
then
eval "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook{{.Extension}} $@"
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook{{.Extension}}"
then
eval "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook{{.Extension}} $@"
elif test -f "$dir/node_modules/lefthook/bin/index.js"
then
eval "$dir/node_modules/lefthook/bin/index.js $@"
elif bundle exec lefthook -h >/dev/null 2>&1
then
bundle exec lefthook $@
elif yarn lefthook -h >/dev/null 2>&1
then
yarn lefthook $@
elif npx @evilmartians/lefthook -h >/dev/null 2>&1
then
npx @evilmartians/lefthook $@
else
echo "Can't find lefthook in PATH"
fi
}
{{.AutoInstall}}
call_lefthook "run {{.HookName}} $@"