fix: creating husky hook with echo fails
Felipellira opened this issue · comments
Felipe Lira commented
Expected Behavior
run
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
to create a git hook
Current Behavior
when i run this
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
it creates the file but when husky tries to run it i get the error
.husky/commit-msg: .husky/commit-msg: cannot execute binary file
husky - commit-msg script failed (code 126)
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
just create the file manually
Steps to Reproduce
1. Install commitlint locally npm install --save-dev @commitlint/config-conventional @commitlint/cli
2. Add configuration file echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
3. Install Husky npm install --save-dev husky
4. Initialize Husky npx husky init
5. Create hook echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
6. Try commit something
Context
No response
commitlint --version
@commitlint/cli@18.6.0
git --version
git version 2.43.0.windows.1
node --version
v20.11.0
Felipe Lira commented
This
echo "module.exports = { extends: ['@commitlint/config-conventional'] };"
create a problematic file too
escapedcat commented
Might be this husky error?: typicode/husky#1372
秋雨不良人 commented
escapedcat commented
Maybe a warning could be added to the docs?
Renan commented
The best way is to create file directly using editor interface.