#!/bin/sh -eu

RUN_BIN=$(realpath "$0")
RUN_DIR=$(dirname "$RUN_BIN")

task="$1"
shift

: "${RUN_TASK:=$task}"

export RUN_BIN
export RUN_DIR
export RUN_TASK

script="$RUN_DIR"/scripts.local/"$task"
[ -f "$script" ] || script="$RUN_DIR"/scripts/"$task"

[ -f "$RUN_DIR"/.env.local ] && . "$RUN_DIR"/.env.local

exec "$script" "$@"
