使用commitizen和cz-customizable规范代码提交
1.安装commitizen和cz-customizable
1 2
| npm install -g commitizen@4.2.4 npm i cz-customizable@6.3.0 --save-dev
|
2.在package.json中进行新增
1 2 3 4 5
| "config": { "commitizen": { "path": "node_modules/cz-customizable" } }
|
3.在根目录下新建.cz-config.js文件并写入配置 之后就可以用 git cz 来代替 git commit
4.使用husky进行强制git代码提交规范
1 2 3
| npm install --save-dev @commitlint/config-conventional@12.1.4 @commitlint/cli@12.1.4 npm install husky@7.0.1 --save-dev npx husky install
|
5.在package.json中新增指令
1
| "prepare": "husky install"
|
6.并执行
7.新增husky配置文件 并往里面写入
1 2
| npx husky add .husky/commit-msg npx --no-install commitlint --edit
|
8、husky规范
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| module.exports = { extends: ['@commitlint/config-conventional'], rules: { 'type-enum': [ 2, 'always', [ 'feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'revert', 'build' ] ], 'subject-case': [0] } }
|