RVCoder
RVCoder

Reputation: 542

git hooks pre-push is not working

Inside git hook folder, I have pre push file inside it i am running "npm run coverage" i.e. command for unit test coverage.

git-hook > pre-push > npm run coverage

but it is not working, can somebody please help me.

Upvotes: 7

Views: 9395

Answers (3)

David
David

Reputation: 1591

check .git/hooks. If it's empty try to uninstall husky and install again. my sh history

 ls .git/hooks
 npm uninstall husky
 npm i husky -D
 ls .git/hooks

it helped me

Upvotes: 3

ElpieKay
ElpieKay

Reputation: 30868

  1. Check if its name is precisely pre-push (not pre-push.sh, not pre-push.py, precisely pre-push, with no file extension).
  2. Check if it's in .git/hooks/. If you have set core.hooksPath=xxx in the config, make sure it's under the directory xxx.
  3. Check if it's executable.
  4. Check if the user that runs pre-push also has the permission to run npm run coverage.

Upvotes: 9

Alvin
Alvin

Reputation: 318

for your short description,I can't locate the reason. But you can tryhusky or ghooks.

husky or ghooks provide git hooks,such as precommit,prepush:

//husky
{
  "scripts": {
    "precommit": "npm test",
    "prepush": "npm run coverage",
    "...": "..."
  }
}

Upvotes: -1

Related Questions