From d147cfe573e46c3b8c0d23cc2a6e26be18602c23 Mon Sep 17 00:00:00 2001 From: andatoshiki <101481353+andatoshiki@users.noreply.github.com> Date: Fri, 24 Mar 2023 16:58:00 +0800 Subject: [PATCH] feat: transpilling all javascript components and utils to typescript as well as affiliated husky features --- .husky/commit-msg | 2 +- scripts/verifyCommit.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scripts/verifyCommit.ts diff --git a/.husky/commit-msg b/.husky/commit-msg index cd4483ae..05a578a0 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -node scripts/verifyCommit.js +node scripts/verifyCommit.ts diff --git a/scripts/verifyCommit.ts b/scripts/verifyCommit.ts new file mode 100644 index 00000000..60254553 --- /dev/null +++ b/scripts/verifyCommit.ts @@ -0,0 +1,17 @@ +import { readFileSync } from 'fs' + +const msg: string = readFileSync('.git/COMMIT_EDITMSG', 'utf-8').trim() + +const commitRE: RegExp = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/ +const mergeRe: RegExp = /^(Merge pull request|Merge branch)/ + +if (!commitRE.test(msg)) { + if (!mergeRe.test(msg)) { + console.log('git commit message does not pass validation') + + console.error(`git commit message format error, use \" title(scope): desc\" as the format`) + process.exit(1) + } +} else { + console.log('git commit message validation test passes') +}