build(git): .githooks补一个 commit-msg + commitlint

This commit is contained in:
sophie committed 2026-06-08 14:07:40 +08:00
1 parent c7f25ec8a1
commit 6057069c1c
9 files changed
+157 -12

No files matched your search

+24
View File
@@ -43,3 +43,27 @@ run_frontend_build() {
npm run build
)
}
ensure_commitlint_deps() {
local root_dir="${1}"
if [[ ! -d "${root_dir}/node_modules/@commitlint/cli" ]]; then
echo "[commit-msg] 根目录 node_modules 不存在,请先执行:"
echo " cd ${root_dir}"
echo " npm install"
echo " 或重新运行: ./scripts/install_git_hooks.sh"
return 1
fi
return 0
}
run_commitlint() {
local root_dir="${1}"
local msg_file="${2}"
if ! ensure_commitlint_deps "${root_dir}"; then
return 1
fi
(
cd "${root_dir}"
npx --no-install commitlint --edit "${msg_file}"
)
}