1

I'm trying to build such a configuration which would work for both command line and Intellij.

Here is a part of my 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"

it works good from command line but when committing with Intellji it says something like

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)

Is thare a solution for this?

humkins
  • 9,635
  • 11
  • 57
  • 75

1 Answers1

2

I just came across this issue myself.

The issue can be resolved quite easily, just add a short-circuit when TTY fails

exec < /dev/tty && git cz --hook || true # <-- Notice the '|| true'

This was also raised as an issue in the official repository of the tool.

see: https://github.com/commitizen/cz-cli/issues/634

elad.chen
  • 2,375
  • 5
  • 25
  • 37