Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:33:44 +08:00
commit 86a1741091
10 changed files with 340 additions and 0 deletions

49
hooks/validate.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Example validation hook that runs after Write/Edit operations
# This demonstrates how to validate file changes
FILE_PATH="$1"
echo "Validating file: $FILE_PATH"
# Check if file exists
if [ ! -f "$FILE_PATH" ]; then
echo "Warning: File not found: $FILE_PATH"
exit 0
fi
# Get file extension
EXT="${FILE_PATH##*.}"
# Perform basic validation based on file type
case "$EXT" in
json)
echo "Checking JSON syntax..."
if command -v jq &> /dev/null; then
if jq empty "$FILE_PATH" 2>/dev/null; then
echo "✓ JSON validation passed"
else
echo "✗ JSON validation failed"
exit 1
fi
else
echo " jq not installed, skipping JSON validation"
fi
;;
sh)
echo "Checking shell script syntax..."
if bash -n "$FILE_PATH" 2>/dev/null; then
echo "✓ Shell script syntax valid"
else
echo "✗ Shell script syntax error"
exit 1
fi
;;
*)
echo " No specific validation for .$EXT files"
;;
esac
echo "Validation complete"
exit 0