feat: 添加 post-edit hook 自动验证 Python 和 JavaScript 文件
- 新增 .qoder/hooks/post-edit-check.sh 脚本 - 编辑 *.py 文件后自动运行 pytest tests/ -x -q - 编辑 static/js/*.js 文件后自动运行 node --check - 配置 PostToolUse hook 监听 Write|Edit 事件 - 更新 .gitignore 跟踪 hooks 目录和 settings.json
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Post-edit hook: 自动验证编辑后的文件
|
||||
# - Python 文件 → 运行 pytest
|
||||
# - JavaScript 文件 → 运行 node --check
|
||||
|
||||
input=$(cat)
|
||||
file_path=$(echo "$input" | jq -r '.tool_input.file_path')
|
||||
|
||||
# 提取相对于项目根的路径
|
||||
rel_path="${file_path#$QODER_PROJECT_DIR/}"
|
||||
|
||||
case "$rel_path" in
|
||||
*.py)
|
||||
echo "🔍 检测到 Python 文件变更: $rel_path" >&2
|
||||
cd "$QODER_PROJECT_DIR" || exit 0
|
||||
.venv/bin/python -m pytest tests/ -x -q
|
||||
;;
|
||||
static/js/*.js)
|
||||
echo "🔍 检测到 JavaScript 文件变更: $rel_path" >&2
|
||||
node --check "$file_path"
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user