Make Git hooks print message when PowerShell not found

This commit is contained in:
YoshiRulz 2024-06-21 22:04:31 +10:00
parent f3ae45b7bd
commit afd496a185
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,10 @@
#!/bin/sh
kind="$(basename "$0")"
pwsh="$(command -v pwsh)"
if [ -z "$pwsh" ]; then pwsh="$(command -v dotnet) pwsh"; fi
if ! ("$pwsh" -v >/dev/null 2>/dev/null); then exit 0; fi
kind="$(basename "$0")"
if ! ("$pwsh" -v >/dev/null 2>/dev/null); then
printf "pwsh not found in PATH; skipping %s hook\n" "$kind"
exit 0
fi
"$pwsh" "./Dist/git_hooks/$kind.ps1" "$@" || exit $?
if [ -e "./Dist/git_hooks/$kind.local.ps1" ]; then "$pwsh" "./Dist/git_hooks/$kind.local.ps1" "$@" || exit $?; fi