【问题标题】:lint-staged + commitizen configuration suitable for command-line and Intellij适用于命令行和 Intellij 的 lint-staged + commitizen 配置
【发布时间】:2019-09-12 21:37:03
【问题描述】:

我正在尝试构建一个适用于命令行和 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 个文件已提交,1 个文件未能提交:feat(asdf): asdfasd fasdf asdfa333 husky > pre-commit (node v10.13.0) 暂存更改... [开始] 暂存更改... [跳过] → 没有部分暂存文件找到... 正在运行 linters... [开始] 为 *.js 运行任务 [开始] eslint --fix [开始] eslint --fix [完成] git add [开始] git add [完成] 为 *.js 运行任务js [已完成] 正在运行 linters... [已完成] husky > prepare-commit-msg (node v10.13.0) /bin/sh: 1: 无法打开 /dev/tty: 没有这样的设备或地址 husky > prepare-commit- msg hook 失败(由于 Git 规范,无法使用 --no-verify 绕过)

有解决办法吗?

【问题讨论】:

    标签: git intellij-idea husky lint-staged commitizen


    【解决方案1】:

    我自己也遇到过这个问题。

    这个问题很容易解决,只需要在TTY失败时添加一个短路

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

    这也是该工具官方存储库中提出的一个问题。

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

    【讨论】:

      猜你喜欢
      • 2020-08-18
      • 2019-06-21
      • 2021-05-24
      • 2022-01-21
      • 2021-10-09
      • 2021-05-12
      • 2018-09-21
      • 2019-08-14
      • 2018-08-04
      相关资源
      最近更新 更多