Add support for hooks in Justfile and Makefile

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-12-31 21:58:26 +01:00
parent 3de0ec13b6
commit aac696fafb
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -2,10 +2,12 @@
HOOKTYPE=$1
if ! [ -e Makefile ]; then
exit 0
if [ -e Justfile ]; then
just --list --list-heading '' --list-prefix '' |
grep -q "auto-hook-${HOOKTYPE}" && exec just "auto-hook-${HOOKTYPE}" || true
fi
if [ -e Makefile ]; then
TARGETS=$(make -pRrq : 2>/dev/null |
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' |
sort | egrep -v -e '^[^[:alnum:]]' | sed 's/:$//' | xargs)
@ -13,3 +15,4 @@ TARGETS=$(make -pRrq : 2>/dev/null |
if (echo $TARGETS | grep -q "auto-hook-${HOOKTYPE}"); then
exec make "auto-hook-${HOOKTYPE}"
fi
fi