Commit is running twice when using commitizen with husky.
See original GitHub issueI 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.
{
"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
prepare-commit-msg
Issue Analytics
- State:
- Created 2 years ago
- Reactions:15
- Comments:9
Top Results From Across the Web
Commitizen and husky seem to be triggering the pre- ...
I am trying to configure commitizen with husky and when I commit using a custom script from package.json commit gets triggered twice.
Read more >Commitizen - GitHub Pages
In essence, npm and husky will run "precommit" scripts twice if you name the script "commit" , and the workaround is to prevent...
Read more >should husky be running precommit hooks twice
should husky be running precommit hooks twice: once before commitizen wizards and again after?
Read more >How To Setup Husky, Lint Staged, And Commitizen On A Next ...
Husky improves your commits and more woof! As I said before about Git Hooks, we can use these hooks to run custom scripts...
Read more >Set up ESLint, Prettier, Commitizen, Husky and friends in 2022
Finally, Commitizen is a tool that is useful in helping to ensure that git ... The next section will show how to use...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
Top GitHub Comments
This may or may not help people here, but we only run commitizen when no commit message is provided.
This means commitizen will not run with
git commit -m
, nor withgit commit --amend
, or for git merge commits etc… See https://git-scm.com/docs/githooks#_prepare_commit_msg for a full list of values the second arg can have.Not sure if this is the problem people here are facing, but it might help someone.
$2 is
template
when rungit commit
not likegit commit -m