全局安装
# 下载
$ yarn global add commitizen cz-conventional-changelog
或者
$ npm install -g commitizen cz-conventional-changelog
# 创建 .czrc 文件写入内容 会在用户文件夹下创建
$ echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
# 完了之后,可以使用 git cz 来代替 git commit 了。
局部安装(我们一般不用)
$ yarn add --dev commitizen cz-conventional-changelog
或者
$ npm install --dev commitizen cz-conventional-changelog
接着往 package.json 添加配置:
{
"scripts": {
"commit": "git-cz",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
完了之后,可以使用 npm run commit 来代替 git commit 了。
参考地址
此文编写于 2019 年 9 月 2 日