commitizen / commitizen/cz-cli

Commit is running twice when using commitizen with husky.

Abierto
#844 13 comentarios 17 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
17.5k
Forks
566
Merge medio
8 h 16 min
PR fusionados (30 d)
1

Descripción

I am trying to configure husky hooks with commitizen and lint-staged. This seems to trigger commit twice when I run `yarn cz` but when I run git commit it runs just once as expected. I have added githooks under the `.husky folder` and the configuration can be seen below. I have already seen the issue mentioned on readme and renamed my script to cz but it doesn't seem to be running as expected.

```json
{
"scripts": {
"cz": "cz",
"dev": "nodemon --watch '**/*.ts' --exec 'ts-node' src/server.ts",
"lint": "eslint . --ext .ts",
"lint-and-format": "eslint . --ext .ts --fix",
"prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"test": "echo \"Error: no test specified\" && exit 1",
"prepare": "husky install",
"build": "tsc",
"start": "NODE_ENV=production yarn build && node dist/server.js"
},
"lint-staged": {
"src/**/*.ts": [
"yarn prettier-format",
"yarn lint-and-format"
],
"*.ts": "eslint --cache --fix"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@typescript-eslint/eslint-plugin": "^4.29.1",
"@typescript-eslint/parser": "^4.29.1",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"lint-staged": ">=10",
"nodemon": "^2.0.12",
"prettier": "^2.3.2",
"ts-node": "^10.2.0",
"typescript": "^4.3.5",
"husky": ">=6"
}
}
```
_`pre-commit`_

![image](https://user-images.githubusercontent.com/22677521/129489749-20e061d7-3568-4001-8f50-9e8c0cfd1a7d.png)

_`prepare-commit-msg`_

![image](https://user-images.githubusercontent.com/22677521/129489764-5b249c1d-d3db-4bc7-87b2-7799952adf30.png)

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.