From 44ae216612b44d4965ad12878785e937ebfe5206 Mon Sep 17 00:00:00 2001 From: liubei Date: Fri, 24 Apr 2026 17:04:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0husky=20pre-commit=20?= =?UTF-8?q?hook=E9=85=8D=E7=BD=AE=E5=AE=9E=E7=8E=B0=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=20(#441)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 配置husky作为pre-commit钩子 - 添加构建验证脚本,提交前自动执行构建检查 - 防止构建失败的代码被提交到仓库 关联任务: 自动化构建门禁方案第一步 --- .husky/pre-commit | 9 +++++++++ package.json | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..2d88ca55 --- /dev/null +++ b/.husky/pre-commit @@ -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 diff --git a/package.json b/package.json index 279edb0c..b0f40c87 100644 --- a/package.json +++ b/package.json @@ -2,5 +2,11 @@ "dependencies": { "axios": "^1.13.2", "json-bigint": "^1.0.0" + }, + "devDependencies": { + "husky": "^9.1.7" + }, + "scripts": { + "prepare": "husky" } -} +} \ No newline at end of file