diff --git a/scripts/test-install.sh b/scripts/test-install.sh index 1459624e9..820d11a72 100644 --- a/scripts/test-install.sh +++ b/scripts/test-install.sh @@ -152,5 +152,36 @@ if [ "$exitCode" -eq 0 ]; then exit 1 fi + +# --- +test "hook should run and pass all HUSKY_GIT_PARAMS" +cat > .huskyrc << EOL +{ + "skipCI": false, + "hooks": { + "prepare-commit-msg": "echo \"prepare-commit-msg hook from Husky\" && echo \$HUSKY_GIT_PARAMS > $hookParamsFile" + } +} +EOL +if [ -f $hookParamsFile ]; then + rm $hookParamsFile +fi + +commit sixth + +if [ ! -f $hookParamsFile ]; then + echo "Fail: hook script didn't run" + exit 1 +fi + +actual=$(cat $hookParamsFile) +expected=".git/COMMIT_EDITMSG message" + +if [ "$actual" != "$expected" ]; then + echo "Fail: HUSKY_GIT_PARAMS weren't set correctly" + echo "$actual != $expected" + exit 1 +fi + echo echo "Success: all tests passed" diff --git a/src/runner/__tests__/index.ts b/src/runner/__tests__/index.ts index 729d6fab3..03c831d62 100644 --- a/src/runner/__tests__/index.ts +++ b/src/runner/__tests__/index.ts @@ -139,7 +139,7 @@ describe('run', (): void => { ) // 'commit-msg' takes one parameter from git - const status = await index(['', '', 'commit-msg', 'git fake param'], { + const status = await index(['', '', 'commit-msg', 'git', 'fake', 'param'], { cwd: dir, }) expectSpawnSyncToHaveBeenCalledWith(dir, 'echo success', {