build(run): prefix tasks with a task: namespace

c949650a80 (task-namespace)
This commit is contained in:
Oliver Davies 2022-04-06 22:22:13 +01:00
parent 178fc87383
commit 6401594548

20
run
View file

@ -8,20 +8,20 @@ set -e
APP_BUILD="${APP_BUILD:=dynamic}" APP_BUILD="${APP_BUILD:=dynamic}"
DOCKER_TAG=meetup-raffle-winner-picker DOCKER_TAG=meetup-raffle-winner-picker
function build { function task:build {
# Build the Docker image. # Build the Docker image.
docker image build . --tag ${DOCKER_TAG} docker image build . --tag ${DOCKER_TAG}
} }
function ci:test { function task:ci:test {
# Run continuous integration (CI) checks. # Run continuous integration (CI) checks.
APP_BUILD=static APP_BUILD=static
build task:build
test --testdox "${@}" task:test --testdox "${@}"
} }
function composer { function task:composer {
# Run Composer commands. # Run Composer commands.
docker container run --rm -it \ docker container run --rm -it \
-v $(pwd):/app \ -v $(pwd):/app \
@ -29,22 +29,22 @@ function composer {
${DOCKER_TAG} "${@}" ${DOCKER_TAG} "${@}"
} }
function console { function task:console {
docker container run --rm -t \ docker container run --rm -t \
--entrypoint php \ --entrypoint php \
${DOCKER_TAG} \ ${DOCKER_TAG} \
bin/console ${@} bin/console ${@}
} }
function help { function task:help {
printf "%s <task> [args]\n\nTasks:\n" "${0}" printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n compgen -A function | sed -En 's/task:(.*)/\1/p' | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n" printf "\nExtended help:\n Each task has comments for general usage\n"
} }
function test { function task:test {
# Run PHPUnit tests. # Run PHPUnit tests.
if [[ $APP_BUILD == "dynamic" ]]; then if [[ $APP_BUILD == "dynamic" ]]; then
docker container run --rm -t -v $PWD:/app --entrypoint phpunit ${DOCKER_TAG} "${@}" docker container run --rm -t -v $PWD:/app --entrypoint phpunit ${DOCKER_TAG} "${@}"
@ -53,4 +53,4 @@ function test {
fi fi
} }
eval "${@:-help}" eval "task:${@:-help}"