Skip to content

Commit cbd0e06

Browse files
typicodeKirk McKelvey
and
Kirk McKelvey
committed
add prepare-commit-msg test
all credit goes to @kirkoman Co-authored-by: Kirk McKelvey <[email protected]>
1 parent 992c1e0 commit cbd0e06

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

scripts/test-install.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,37 @@ if [ "$exitCode" -eq 0 ]; then
152152
exit 1
153153
fi
154154

155+
# ---
156+
test "hook should run and pass all HUSKY_GIT_PARAMS"
157+
cat > .huskyrc << EOL
158+
{
159+
"skipCI": false,
160+
"hooks": {
161+
"prepare-commit-msg": "echo \"prepare-commit-msg hook from Husky\" && echo \$HUSKY_GIT_PARAMS > $hookParamsFile"
162+
}
163+
}
164+
EOL
165+
if [ -f $hookParamsFile ]; then
166+
rm $hookParamsFile
167+
fi
168+
169+
commit sixth
170+
171+
if [ ! -f $hookParamsFile ]; then
172+
echo "Fail: hook script didn't run"
173+
exit 1
174+
fi
175+
176+
actual=$(cat $hookParamsFile)
177+
expected=".git/COMMIT_EDITMSG message"
178+
179+
if [ "$actual" != "$expected" ]; then
180+
echo "Fail: HUSKY_GIT_PARAMS weren't set correctly"
181+
echo "$actual != $expected"
182+
exit 1
183+
fi
184+
155185
echo
156186
echo "Success: all tests passed"
187+
188+

0 commit comments

Comments
 (0)