Files
ComfyUI-OpenClaw/scripts/precommit_black_single.sh
T

22 lines
790 B
Bash

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
# Keep Black cache local to avoid AppData lock/permission errors on Windows.
export BLACK_CACHE_DIR="${BLACK_CACHE_DIR:-$ROOT_DIR/.tmp/black-cache}"
mkdir -p "$BLACK_CACHE_DIR"
if command -v python >/dev/null 2>&1; then
# CRITICAL cross-platform guard:
# WSL sometimes has only `python3`, while Windows shells usually expose `python`.
# Keep this fallback chain to avoid false hook failures like "Executable `python` not found".
exec python -B scripts/precommit_black_single.py "$@"
fi
if command -v python3 >/dev/null 2>&1; then
exec python3 -B scripts/precommit_black_single.py "$@"
fi
echo "ERROR: python interpreter not found (need python or python3 in PATH)." >&2
exit 127