fix: harden cross-platform quality tooling
This commit is contained in:
+14
-2
@@ -6,14 +6,26 @@ set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
python_formatter() {
|
||||
local python_command
|
||||
for python_command in python python3; do
|
||||
if command -v "$python_command" &>/dev/null &&
|
||||
"$python_command" -m gdtoolkit.formatter --help &>/dev/null 2>&1; then
|
||||
echo "$python_command"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# detect gdformat
|
||||
FMT=()
|
||||
if [[ -x "$ROOT/.venv/bin/gdformat" ]]; then
|
||||
FMT=("$ROOT/.venv/bin/gdformat")
|
||||
elif command -v gdformat &>/dev/null; then
|
||||
FMT=(gdformat)
|
||||
elif python -m gdtoolkit.formatter --help &>/dev/null 2>&1; then
|
||||
FMT=(python -m gdtoolkit.formatter)
|
||||
elif PYTHON_FORMATTER="$(python_formatter)"; then
|
||||
FMT=("$PYTHON_FORMATTER" -m gdtoolkit.formatter)
|
||||
fi
|
||||
|
||||
if [[ ${#FMT[@]} -eq 0 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user