1+ #! /bin/sh
2+
3+ if [ " $LEFTHOOK_VERBOSE " = " 1" -o " $LEFTHOOK_VERBOSE " = " true" ]; then
4+ set -x
5+ fi
6+
7+ if [ " $LEFTHOOK " = " 0" ]; then
8+ exit 0
9+ fi
10+
11+ call_lefthook ()
12+ {
13+ if test -n " $LEFTHOOK_BIN "
14+ then
15+ " $LEFTHOOK_BIN " " $@ "
16+ elif lefthook -h > /dev/null 2>&1
17+ then
18+ lefthook " $@ "
19+ else
20+ dir=" $( git rev-parse --show-toplevel) "
21+ osArch=$( uname | tr ' [:upper:]' ' [:lower:]' )
22+ cpuArch=$( uname -m | sed ' s/aarch64/arm64/;s/x86_64/x64/' )
23+ if test -f " $dir /node_modules/lefthook-${osArch} -${cpuArch} /bin/lefthook"
24+ then
25+ " $dir /node_modules/lefthook-${osArch} -${cpuArch} /bin/lefthook" " $@ "
26+ elif test -f " $dir /node_modules/@evilmartians/lefthook/bin/lefthook-${osArch} -${cpuArch} /lefthook"
27+ then
28+ " $dir /node_modules/@evilmartians/lefthook/bin/lefthook-${osArch} -${cpuArch} /lefthook" " $@ "
29+ elif test -f " $dir /node_modules/@evilmartians/lefthook-installer/bin/lefthook"
30+ then
31+ " $dir /node_modules/@evilmartians/lefthook-installer/bin/lefthook" " $@ "
32+ elif test -f " $dir /node_modules/lefthook/bin/index.js"
33+ then
34+ " $dir /node_modules/lefthook/bin/index.js" " $@ "
35+
36+ elif bundle exec lefthook -h > /dev/null 2>&1
37+ then
38+ bundle exec lefthook " $@ "
39+ elif yarn lefthook -h > /dev/null 2>&1
40+ then
41+ yarn lefthook " $@ "
42+ elif pnpm lefthook -h > /dev/null 2>&1
43+ then
44+ pnpm lefthook " $@ "
45+ elif swift package plugin lefthook > /dev/null 2>&1
46+ then
47+ swift package --disable-sandbox plugin lefthook " $@ "
48+ elif command -v mint > /dev/null 2>&1
49+ then
50+ mint run csjones/lefthook-plugin " $@ "
51+ elif command -v npx > /dev/null 2>&1
52+ then
53+ npx lefthook " $@ "
54+ else
55+ echo " Can't find lefthook in PATH"
56+ fi
57+ fi
58+ }
59+
60+ call_lefthook run " prepare-commit-msg" " $@ "
0 commit comments