diff --git a/run b/run index 3dbb393..d9124fc 100755 --- a/run +++ b/run @@ -1,16 +1,27 @@ #!/bin/sh -e -export RUN_BIN="$0" -export RUN_DIR=$(dirname "$(realpath "$0")") +RUN_BIN="$0" +RUN_DIR=$(dirname "$(realpath "$0")") -task= -if [ -e "$RUN_DIR/scripts/$1" ]; then +export RUN_BIN +export RUN_DIR + +if [ "$(dirname "$0")" = ".git/hooks" ]; then + task=$(basename "$0") +else task="$1" -elif [ -e "$RUN_DIR/scripts/local/$1" ]; then - task="local/$1" + [ $# -gt 0 ] && shift fi -[ -z "$task" ] && exit 1 +script= +if [ -x "$RUN_DIR/scripts/local/$task" ]; then + script="local/$task" +elif [ -x "$RUN_DIR/scripts/git-hooks/$task" ]; then + script="git-hooks/$task" +elif [ -x "$RUN_DIR/scripts/$task" ]; then + script="$task" +fi -shift -exec "$RUN_DIR/scripts/$task" "$@" +[ -z "$script" ] && exit 1 + +exec "$RUN_DIR/scripts/$script" "$@" diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit new file mode 120000 index 0000000..b43092b --- /dev/null +++ b/scripts/git-hooks/pre-commit @@ -0,0 +1 @@ +../lint \ No newline at end of file