'Commitizen and husky seem to be triggering the pre-commit hook twice

I am trying to configure commitizen with husky and when I commit using a custom script from package.json commit gets triggered twice. This is not the case when I try to run git commit though.

Opened the issue on github but if anyone knows any workaround for this that would be great

Github Issue: https://github.com/commitizen/cz-cli/issues/844

Below is the package.json

{
  "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"
  }
}

Huskt hooks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source