規範Git Commit Message
阿新 • • 發佈:2018-12-20
讓Commitlint支援Angular規範
一、安裝依賴:
1、自動檢測依賴安裝
npm install --save-dev @commitlint/config-angular @commitlint/cli
或者用yarn
yarn add @commitlint/config-angular @commitlint/cli -D
2、配置 husky (pre-commit)
npm install husky --save-dev
或者用yarn方式
yarn add husky -D
二、專案根目錄下建立
commitlint.config.js:
module.exports = {extends: ['@commitlint/config-angular']};
三、配置 husky 到 package.json
"husky": {
"hooks": {
"pre-commit": [
"npm run lint"
],
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"dependencies":{
。。。。。
}
四、配置commitmsg
在package.json下配置commitmsg scripts
它將在每一次commit之前都會觸發這個指令碼
"scripts": {
"test": "./node_modules/.bin/nightwatch",
"e2e-report": "node create-html-report.js",
"lint": "./node_modules/.bin/commitlint -env $GIT_PARAMS" (注意這裡用-env或者-E 不能用-e)
},