File tree Expand file tree Collapse file tree 3 files changed +59
-8
lines changed
Expand file tree Collapse file tree 3 files changed +59
-8
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ . " $( dirname " $0 " ) /_/husky.sh"
3+
4+ # 需要检查的文件列表(可按需修改文件名和路径)
5+ files=" ezuikit.js index.js index.mjs"
6+
7+ version=" "
8+ inconsistent=false
9+
10+ for file in $files ; do
11+ if [ ! -f " $file " ]; then
12+ echo " 缺少文件: $file "
13+ inconsistent=true
14+ continue
15+ fi
16+ # 提取头部前2行(防止文件太大),你可以根据实际格式修改正则
17+ v=$( head -2 " $file " | grep -Eo ' v([0-9]+\.[0-9]+\.[0-9]+)+(-[a-z]+\.[0-9]+)?' )
18+ if [ -z " $v " ]; then
19+ echo " 文件 $file 未检测到版本号"
20+ inconsistent=true
21+ continue
22+ fi
23+ if [ -z " $version " ]; then
24+ version=" $v "
25+ else
26+ if [ " $version " != " $v " ]; then
27+ echo " 文件 $file 的版本号 $v 与其它文件版本号 $version 不一致"
28+ inconsistent=true
29+ fi
30+ fi
31+ done
32+
33+ if [ " $inconsistent " = true ]; then
34+ echo " 版本号不一致,禁止推送!"
35+ exit 1
36+ fi
37+
38+ echo " 所有文件版本号一致: $version "
Original file line number Diff line number Diff line change 3232 "abortcontroller-polyfill" : " ^1.7.5" ,
3333 "debounce-promise" : " ^3.1.2" ,
3434 "deepmerge" : " ^4.3.1" ,
35+ "delegate" : " 3.2.0" ,
3536 "formdata-polyfill" : " ^4.0.10" ,
3637 "jquery" : " ^3.3.1" ,
3738 "lodash-es" : " ^4.17.21" ,
3839 "screenfull" : " ^5.2.0" ,
39- "uuid" : " ^8.3.0" ,
40- "delegate" : " 3.2.0"
40+ "uuid" : " ^8.3.0"
4141 },
42- "peerDependencies" : {},
4342 "license" : " ISC" ,
4443 "repository" : {
4544 "type" : " git" ,
4847 "bugs" : {
4948 "url" : " https://github.com/Ezviz-OpenBiz/EZUIKit-JavaScript-npm/issues"
5049 },
51- "homepage" : " https://github.com/Ezviz-OpenBiz/EZUIKit-JavaScript-npm#readme"
50+ "homepage" : " https://github.com/Ezviz-OpenBiz/EZUIKit-JavaScript-npm#readme" ,
51+ "devDependencies" : {
52+ "husky" : " ^9.1.7"
53+ }
5254}
You can’t perform that action at this time.
0 commit comments