Add support for hooks in Justfile and Makefile
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
3de0ec13b6
commit
aac696fafb
1 changed files with 10 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue