commitizen / commitizen/cz-cli

Update Documentation for pre-commit hooks with Husky 5

未关闭
#810 1 条评论 8 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
17.5k
派生
566
平均合并
8 小时 16 分钟
30 天内合并 PR
1

描述

Hi commitizeners :)

I love using commitizen on my projects, and with husky hooks for pre-commit is great.

BUT... There is a new version of Husky, (Husky 5) which breaks how hooks are set up. That means the commitizen documentation is now out of date (because it only describes from Husky 4).

## PROBLEM:

The commitizen documentation is out of date for Husky 5.

## Main Differences:

In Husky 4, you add a husky hook to package.json and install commitizen and husky. Husky automatically registers the hook.

Now... in Husky 5, the hooks are added to separate files (NOT package.json)

## SOLUTION:

Brief instructions follow, which I suggest to be added to the commitizen documentation.

#### Using Commitizen with Husky 5

Install husky:

npm install--save-dev husky

Then run this to add a pre commit message hook:

npx husky add .husky/prepare-commit-msg "exec < /dev/tty && git cz --hook || true"

Note, you will probably want to add the resulting hook file to git:

.husky/prepare-commit-msg

UPDATE: If your hooks don't run, you can tell Husky to install them:

npx husky install

Hope that is helpful!

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。