From 015f3aae2ff14b5e0a71e2dd73adebdc0bf07749 Mon Sep 17 00:00:00 2001 From: typicode Date: Wed, 12 Feb 2020 04:09:57 +0100 Subject: [PATCH] fix husky.sh syntax error --- sh/husky.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sh/husky.sh b/sh/husky.sh index 48afbd177..aabf9fe76 100644 --- a/sh/husky.sh +++ b/sh/husky.sh @@ -35,7 +35,7 @@ hookIsDefined () { .huskyrc \ .huskyrc.json \ .huskyrc.yaml \ - .huskyrc.yml \ + .huskyrc.yml } huskyVersion="0.0.0" @@ -55,7 +55,10 @@ fi debug "Current working directory is $(pwd)" # Skip fast if hookName is not defined -if ! hookIsDefined; then +# Don't skip if .huskyrc.js or .huskyrc.config.js are used as the heuristic could +# fail due to the dynamic aspect of JS. For example: +# `"pre-" + "commit"` or `require('./config/hooks')`) +if [ ! -f .huskyrc.js ] && [ ! -f .huskyrc.config.js ] && ! hookIsDefined; then debug "$hookName config not found, skipping hook" exit 0 fi