i18n(uk): add missing files, translate P4 root docs
- Copy code/image/config files across all modules - Translate brand-voice and code-review templates - Translate CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, STYLE_GUIDE - Copy CHANGELOG as-is (technical log) Ref: luongnv89/claude-howto#63
This commit is contained in:
49
uk/06-hooks/format-code.sh
Normal file
49
uk/06-hooks/format-code.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
# Auto-format code after writing
|
||||
# Hook: PostToolUse:Write
|
||||
#
|
||||
# Reads the target file path from stdin JSON and runs the appropriate formatter
|
||||
# in-place on the file after Claude writes it.
|
||||
#
|
||||
# Compatible with: macOS, Linux, Windows (Git Bash)
|
||||
|
||||
# Read JSON input from stdin (Claude Code hook protocol)
|
||||
INPUT=$(cat)
|
||||
|
||||
# Extract file_path using sed (compatible with all platforms)
|
||||
FILE_PATH=$(echo "$INPUT" | sed -n 's/.*"file_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' | head -1)
|
||||
|
||||
if [ -z "$FILE_PATH" ] || [ ! -f "$FILE_PATH" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Detect file type and format accordingly
|
||||
case "$FILE_PATH" in
|
||||
*.js|*.jsx|*.ts|*.tsx)
|
||||
if command -v prettier &> /dev/null; then
|
||||
prettier --write "$FILE_PATH" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
*.py)
|
||||
if command -v black &> /dev/null; then
|
||||
black "$FILE_PATH" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
*.go)
|
||||
if command -v gofmt &> /dev/null; then
|
||||
gofmt -w "$FILE_PATH" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
*.rs)
|
||||
if command -v rustfmt &> /dev/null; then
|
||||
rustfmt "$FILE_PATH" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
*.java)
|
||||
if command -v google-java-format &> /dev/null; then
|
||||
google-java-format -i "$FILE_PATH" 2>/dev/null
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user