feat: 添加husky pre-commit hook配置实现构建验证 (#441)

- 配置husky作为pre-commit钩子
- 添加构建验证脚本,提交前自动执行构建检查
- 防止构建失败的代码被提交到仓库

关联任务: 自动化构建门禁方案第一步
This commit is contained in:
2026-04-24 17:04:49 +08:00
parent fe2a79773f
commit 44ae216612
2 changed files with 16 additions and 1 deletions

9
.husky/pre-commit Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env sh
# 前端构建检查
cd openhis-ui-vue3
# 检查是否安装了lint-staged或eslint
if npm list --depth=0 | grep -q "eslint"; then
npm run lint -- --max-warnings 0
fi
# 执行生产构建检查
npm run build:prod -- --mode development 2>/dev/null || exit 1

View File

@@ -2,5 +2,11 @@
"dependencies": {
"axios": "^1.13.2",
"json-bigint": "^1.0.0"
},
"devDependencies": {
"husky": "^9.1.7"
},
"scripts": {
"prepare": "husky"
}
}