Search code examples
node.jsnpmpre-commit-hookpre-commit

pre-git's pre-commit hook is not waiting for the task to complete


Our pre-git configuration in package.json looks like

"pre-git": {
      "pre-commit": [
        "npm run lint",
        "npm run coverage",
        "npm run coverage-check"
      ],
      "post-commit": [
        "git status"
      ]
    }

But, the "pre-commit" hook is not waiting for "npm run coverage" to complete (which is an istanbul cover task). npm run coverage runs fine individually. Are we missing something?

Thanks


Solution

  • Try not using "npm run" ... Just list the tools by them aliases available on scripts section. This is the way I worked with NodeJS. "pre-git" is new to me. I used directly a package called "pre-commit" which worked fine the way I just described.

    Then, for a more generic solution, I wrote this tool:

    https://pypi.org/project/hooks4git/