📦 deps(thirdparty): update snapshots
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Post-Tool-Use Hook: Auto-format TypeScript files after Write/Edit
|
||||
# This hook runs automatically after Claude writes or edits .ts files
|
||||
|
||||
# Read hook input from stdin
|
||||
INPUT=$(cat)
|
||||
|
||||
# Extract file path from the tool input
|
||||
FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty')
|
||||
|
||||
# Validate file path exists
|
||||
if [[ -z "$FILE_PATH" ]]; then
|
||||
echo "No file path provided" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if file exists
|
||||
if [[ ! -f "$FILE_PATH" ]]; then
|
||||
echo "File not found: $FILE_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Format the file with biome (adjust to your formatter)
|
||||
echo "Formatting $FILE_PATH..."
|
||||
|
||||
if command -v biome &>/dev/null; then
|
||||
biome check --write "$FILE_PATH" 2>&1 || {
|
||||
echo "Warning: biome formatting failed for $FILE_PATH" >&2
|
||||
exit 0 # Non-blocking warning
|
||||
}
|
||||
echo "✓ Formatted successfully"
|
||||
elif command -v prettier &>/dev/null; then
|
||||
prettier --write "$FILE_PATH" 2>&1 || {
|
||||
echo "Warning: prettier formatting failed for $FILE_PATH" >&2
|
||||
exit 0
|
||||
}
|
||||
echo "✓ Formatted successfully"
|
||||
else
|
||||
echo "Warning: No formatter found (biome or prettier)" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"hooks": {
|
||||
"PostToolUse": [
|
||||
{
|
||||
"matcher": "Write|Edit(*.ts)",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/format.sh",
|
||||
"timeout": 30
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user