fix: relax run tool - #151
Conversation
| local installer="${SCRIPT_DIR}/internal/devcontainer/install.py" | ||
| command -v python3 >/dev/null 2>&1 || return 1 | ||
| [[ -f "${installer}" ]] || return 1 | ||
| python3 "${installer}" version "${tool_name}" 2>/dev/null |
There was a problem hiding this comment.
I prefer that tool_name is passed in as argument like it is done at installed_version
| installed_version() { | ||
| local tool="$1" arg output version | ||
| while IFS= read -r arg; do | ||
| if output=$("${tool}" "${arg}" </dev/null 2>&1); then |
There was a problem hiding this comment.
This script sets -euo pipefail. Will it fail, when the tool returns an error? Imagine a tool understands -v but not --version or -version.
There was a problem hiding this comment.
No; because the command runs in an if condition, set -e ignores its non-zero status, the loop continues through all version flags, and if none succeeds, installed_version returns 1, causing the local check to fail and run-tool to fall back to Bazel.
There was a problem hiding this comment.
because the script got more complicated, I would like to have tests added.
There was a problem hiding this comment.
New test run-tool to cover local version fallback has been added
Enhanced the script to avoid unnecessary Bazel execution when a matching local tool is available.
Closes #148