From 1239a1953f3416867eadfd3b61ac4c4478466a8f Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Wed, 10 Aug 2022 14:12:33 +0300 Subject: [PATCH 1/2] fix: Check for lefthook.bat in hook template Signed-off-by: Valentin Kiselev --- internal/templates/hook.tmpl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/templates/hook.tmpl b/internal/templates/hook.tmpl index 4a6c13c5..efe0b996 100644 --- a/internal/templates/hook.tmpl +++ b/internal/templates/hook.tmpl @@ -17,6 +17,9 @@ call_lefthook() if lefthook{{.Extension}} -h >/dev/null 2>&1 then eval lefthook{{.Extension}} $@ + elif [ -n "{{.Extension}}" ] && lefthook.bat -h >/dev/null 2>&1 + then + eval lefthook.bat $@ 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}} $@" From 98a00bce01bc74f1a852c57ca02d1971af9cbffc Mon Sep 17 00:00:00 2001 From: Valentin Kiselev Date: Wed, 10 Aug 2022 14:34:26 +0300 Subject: [PATCH 2/2] chore: Use go template instead of sh checks Signed-off-by: Valentin Kiselev --- internal/templates/hook.tmpl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/templates/hook.tmpl b/internal/templates/hook.tmpl index efe0b996..4511c18d 100644 --- a/internal/templates/hook.tmpl +++ b/internal/templates/hook.tmpl @@ -17,9 +17,12 @@ call_lefthook() if lefthook{{.Extension}} -h >/dev/null 2>&1 then eval lefthook{{.Extension}} $@ - elif [ -n "{{.Extension}}" ] && lefthook.bat -h >/dev/null 2>&1 + {{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}} $@"