Git提交规范
方跃明 2020-01-02
Husky接管Git钩子在commit-msg时利用commitlint检查提交规范。
参考
实现
安装开发依赖
shell
yarn install -D husky
yarn install -D @commitlint/cli
yarn install -D @commitlint/config-conventional配置package.json
json
{
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
}commit规范
shell
type(scope?): subject #scope is optional生成CHANGELOG
安装依赖
shell
yarn install -D conventional-changelog
yarn install -D conventional-changelog-clipackage.json
json
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
}生成
shell
yarn changelog # 在项目根目录生成CHANGELOG.mdGit钩子执行ESLint
详见规范构建教程