我正在尝试构建一种适用于命令行和Intellij的配置。
这是我的package.json
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"prepare-commit-msg": "exec < /dev/tty && git cz --hook",
"commit-msg": "validate-commit-msg"
}
},
"devDependencies": {
"commitizen": "^3.1.1",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^5.15.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jest": "^22.4.1",
"husky": "^1.3.1",
"lint-staged": "^8.1.5",
"standard-version": "^5.0.1",
"validate-commit": "^3.4.0"
它在命令行中运行良好,但是在使用Intellji时它表示类似
0 files committed, 1 file failed to commit: feat(asdf): asdfasd fasdf asdfa333 husky > pre-commit (node v10.13.0) Stashing changes... [started] Stashing changes... [skipped] → No partially staged files found... Running linters... [started] Running tasks for *.js [started] eslint --fix [started] eslint --fix [completed] git add [started] git add [completed] Running tasks for *.js [completed] Running linters... [completed] husky > prepare-commit-msg (node v10.13.0) /bin/sh: 1: cannot open /dev/tty: No such device or address husky > prepare-commit-msg hook failed (cannot be bypassed with --no-verify due to Git specs)
这是解决方案吗?
答案 0 :(得分:0)
我自己碰到了这个问题。
可以很容易地解决该问题,只需在TTY失败时添加短路
exec < /dev/tty && git cz --hook || true # <-- Notice the '|| true'
在该工具的官方存储库中也提出了这一问题。