diff --git a/cli.sh b/cli.sh index f70f4ad..62e3db0 100755 --- a/cli.sh +++ b/cli.sh @@ -3,7 +3,7 @@ # Simple CLI wrapper that discovers scripts in the commands/ directory # Cd to the directory of this script, so it can be run from anywhere -cd "$(dirname "$0")" || exit 1 +cd "$(dirname "$(realpath "$0")")" || exit 1 # Color codes RESET="\e[0m" diff --git a/tests/test-cli.sh b/tests/test-cli.sh index 8ba5fed..d956ac0 100755 --- a/tests/test-cli.sh +++ b/tests/test-cli.sh @@ -13,6 +13,7 @@ PROJECT_ROOT="$(dirname "$(dirname "$(realpath "$0")")")" cleanup() { rm "$PROJECT_ROOT/$TEST_CMD_PATH" || true rm "$PROJECT_ROOT/$HELP_TXT_PATH" || true + rm "$PROJECT_ROOT/tests/cli-symlink.sh" || true } trap cleanup EXIT @@ -45,6 +46,18 @@ cd .. echo "OK" echo +echo "Testing cli.sh as a symlink from tests directory, to proove that it can be run as a symlink from anywhere..." +cd tests +ln -s ../cli.sh ./cli-symlink.sh +OUT=$(./cli-symlink.sh) +if [[ "$OUT" != *"$TEST_CMD"* ]]; then + echo "FAIL: Test command $TEST_CMD not found when running cli.sh as a symlink from tests dir" + exit 1 +fi +cd .. +echo "OK" +echo + echo "Testing cli.sh list sub-command to check output..." OUT=$(./cli.sh list) if [[ "$OUT" != *"$TEST_CMD"* ]]; then