mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
39 lines
865 B
TypeScript
39 lines
865 B
TypeScript
import { readFileSync } from 'fs-extra';
|
|
import { logger } from '../common/logger';
|
|
|
|
const commitRE = /^(revert: )?(fix|feat|docs|perf|test|types|build|chore|refactor|breaking change)(\(.+\))?: .{1,50}/;
|
|
const mergeRE = /Merge branch /;
|
|
|
|
export function commitLint() {
|
|
const gitParams = process.env.HUSKY_GIT_PARAMS as string;
|
|
const commitMsg = readFileSync(gitParams, 'utf-8').trim();
|
|
|
|
if (!commitRE.test(commitMsg) && !mergeRE.test(commitMsg)) {
|
|
logger.error(`Error: invalid commit message: "${commitMsg}".
|
|
|
|
Proper commit message format is required for automated changelog generation.
|
|
|
|
Examples:
|
|
|
|
- fix(Button): incorrect style
|
|
- feat(Button): incorrect style
|
|
- docs(Button): fix typo
|
|
|
|
Allowed Types:
|
|
|
|
- fix
|
|
- feat
|
|
- docs
|
|
- perf
|
|
- test
|
|
- types
|
|
- build
|
|
- chore
|
|
- refactor
|
|
- breaking change
|
|
- Merge branch 'foo' into 'bar'
|
|
`);
|
|
process.exit(1);
|
|
}
|
|
}
|