This commit is contained in:
2024-02-02 22:31:01 +08:00
parent 06a5f041bf
commit 486ea5013a
77 changed files with 17507 additions and 122 deletions

19
scripts/verifyCommit.js Normal file
View File

@@ -0,0 +1,19 @@
const path = require('node:path');
const fs = require('node:fs');
const pc = require('picocolors');
const msgPath = path.resolve('.git/COMMIT_EDITMSG');
const msg = fs.readFileSync(msgPath, 'utf-8').trim();
const commitRE =
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/;
if(!commitRE.test(msg)) {
console.log();
console.error(
` ${pc.bgRed(pc.white(' ERROR '))} ${pc.red('Git提交信息不符合规范!')}\n\n${pc.green(
'推荐使用命令 npm run cz 生成符合规范的Git提交信息'
)}\n`
);
process.exit(1);
}