2016-12-12 15:57:39 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
HOOKTYPE=$1
|
|
|
|
|
2021-12-31 20:58:26 +00:00
|
|
|
if [ -e Justfile ]; then
|
2022-09-19 14:28:05 +00:00
|
|
|
just --list --list-heading '' --list-prefix '' |
|
|
|
|
grep -q "auto-hook-${HOOKTYPE}" && exec just "auto-hook-${HOOKTYPE}" || true
|
2016-12-12 15:57:39 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-31 20:58:26 +00:00
|
|
|
if [ -e Makefile ]; then
|
2022-09-19 14:28:05 +00:00
|
|
|
TARGETS=$(make -pRrq : 2>/dev/null |
|
|
|
|
awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' |
|
|
|
|
sort | grep -E -v -e '^[^[:alnum:]]' | sed 's/:$//' | xargs)
|
2016-12-12 15:57:39 +00:00
|
|
|
|
2022-09-19 14:28:05 +00:00
|
|
|
if (echo $TARGETS | grep -q "auto-hook-${HOOKTYPE}"); then
|
|
|
|
exec make "auto-hook-${HOOKTYPE}"
|
|
|
|
fi
|
2016-12-12 15:57:39 +00:00
|
|
|
fi
|