post-edit-pint.sh runs vendor/bin/pint --dirty from api/ after any .php edit. post-edit-eslint.sh runs pnpm eslint --fix inside the matching SPA dir for .vue/.ts/.tsx/.js files under apps/app/ or apps/portal/. Both exit 0 unconditionally — formatting failures must not block the agent.
30 lines
834 B
Bash
Executable File
30 lines
834 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
input="$(cat)"
|
|
path="$(echo "$input" | jq -r '.tool_input.file_path // .tool_input.path // empty')"
|
|
|
|
[ -z "$path" ] && exit 0
|
|
|
|
# Strip leading absolute prefix if present, so we match repo-relative paths.
|
|
rel="$path"
|
|
if [[ "$path" = /* ]]; then
|
|
rel="${path#$CLAUDE_PROJECT_DIR/}"
|
|
fi
|
|
|
|
# Match apps/app/** or apps/portal/** for .vue/.ts/.tsx/.js files.
|
|
if ! echo "$rel" | grep -Eq '^apps/(app|portal)/.+\.(vue|ts|tsx|js)$'; then
|
|
exit 0
|
|
fi
|
|
|
|
# Extract SPA dir and the path relative to it.
|
|
spa="$(echo "$rel" | grep -oE '^apps/(app|portal)')"
|
|
inside="${rel#$spa/}"
|
|
|
|
# SPA may not exist yet (apps/portal/ is planned but not present in tree).
|
|
[ -d "$CLAUDE_PROJECT_DIR/$spa" ] || exit 0
|
|
|
|
cd "$CLAUDE_PROJECT_DIR/$spa" 2>/dev/null || exit 0
|
|
pnpm eslint --fix "$inside" >/dev/null 2>&1 || true
|
|
exit 0
|