husky icon indicating copy to clipboard operation
husky copied to clipboard

Feature: option to exec hooks in the default `.git/hooks` location if present

Open J-Chris-Findlay-RESIDEO opened this issue 3 months ago • 0 comments

Troubleshoot

  • [x] Before creating an issue, please check: https://typicode.github.io/husky/troubleshoot.html

~If you're migrating from husky 4, see:~ ~https://typicode.github.io/husky/migrate-from-v4.html~

Context Please describe your issue and provide some context:

  • Any

I have some custom hooks I add to every repo but work recently added husky to a repo I work in to lint pre-commit, but it means my custom hooks no longer run as the hookspath is changed.

It would be great if there was a simple way to effectively have each hook additionally run ones in the default location if present, after whatever husky was set up to run, e.g. as if each hook ended with:

s=$(basename "$0")
h=".git/hooks/$s"
if [ -f $h ]; then
	#echo "~~~~~~~~ Exec $h" "$@" "..."
	$h "$@"
	c=$?
	#echo "~~~~~~~~ Return: $c"
	[ $c != 0 ] && exit $c
fi
exit 0

I suspect adding something like this to .husky/_/h might work..tho it'd need to back up another dir in my case?

J-Chris-Findlay-RESIDEO avatar Sep 04 '25 02:09 J-Chris-Findlay-RESIDEO