post-edit-format.sh
来自
cli/templates/level-2/
bash
#!/usr/bin/env bash
set -euo pipefail
input=$(cat)
file_path=$(echo "$input" | jq -r '.tool_input.file_path // ""')
# Only format project source files
case "$file_path" in
*.ts|*.tsx|*.js|*.jsx|*.json)
if command -v npx &>/dev/null; then
npx prettier --write "$file_path" 2>/dev/null || true
fi
;;
esac
exit 0