Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-push not work #322

Closed
wfsovereign opened this issue Jul 26, 2018 · 10 comments
Closed

pre-push not work #322

wfsovereign opened this issue Jul 26, 2018 · 10 comments

Comments

@wfsovereign
Copy link

"husky": "^0.14.3"
system: osx 10.13.6
node version: v8.11.3

 "husky": {
    "hooks": {
      "pre-push": "npm run lint"
    }
  },

don't work

@badddams
Copy link

I'm also experiencing the same thing, however if I use version: 1.0.0-rc.13 everything works fine.

@aguynamedben
Copy link

Same thing, pre-push hooks didn't work until I specified that specific version.

Install command

$ yarn add --dev husky@v1.0.0-rc.13

package.json

  "husky": {
    "hooks": {
      "pre-push": "npm run test"
    }
  },

@typicode
Copy link
Owner

Hi @wfsovereign,

husky field in package.json is actually only supported by v1.

Thanks for the help @Ubiquitous23, @aguynamedben 👍

@wfsovereign
Copy link
Author

thanks everybody

v-stickykeys pushed a commit to ResearchHub/researchhub-web that referenced this issue Oct 3, 2019
@cassmtnr
Copy link

cassmtnr commented May 3, 2020

Works with this:

Same thing, pre-push hooks didn't work until I specified that specific version.

Install command

$ yarn add --dev husky@v1.0.0-rc.13

package.json

  "husky": {
    "hooks": {
      "pre-push": "npm run test"
    }
  },

Don't work with latest version.

@brettz9
Copy link

brettz9 commented Jul 9, 2020

Should this be reopened per the last comment? (In my case, we had preexisting hooks, but running npm rebuild still didn't help.)

@swesleylokiandthor
Copy link

Another vote for reopening this please

@atul161
Copy link

atul161 commented Oct 14, 2021

Hii @swesleylokiandthor @azu @fearphage @ahutchings @alexeyten @calendee

Documentation of husky is telling that you automatic configure husky but that is not working correctly.

I have figured it out. You neeed unisntall the husky first using command npm uninstall husky and after that again install it using command npm install husky --save-dev . Now run the listed command

  • npx husky install
  • npm set-script prepare "husky install"
  • npx husky add .husky/pre-commit "Add your coomand here ie lint staged npm test etc"
  • If you want to add pre-push then run npx husky add .husky/pre-push "your command here ie. npm run type-check"
  • Now add the following thing into package.json
 "husky": {
    "hooks": {
      "pre-commit": "lint-staged",
      "pre-push": "npm run type-check"
    }
  • If you are using husky for linter then add this also in package.json
  "lint-staged": {
    "*.@(ts|tsx)": [
      "npm run lint",
      "npm run  format"
    ]
  }
  
  • Now try to commit . Note that dont add .husky into gitignore because sometimes husky will not work for other developer and if .husky folder is present same for every developer then it will work correctly.
  • If you get an error like husky not found then go to package.json and remove prepare husky install and run npm install again

@rajjaiswalsaumya
Copy link

rajjaiswalsaumya commented Oct 30, 2021

husky is not working for me too. I am on windows 10, and have prepare command in my package.json, and have latest husky 7.0.4 installed as of now. I have git version 2.32.0.windows.2. I have pretty-quick installed. I have package.json having script "husky": { "hooks": { "pre-commit": "pretty-quick --staged" } }

Also this command in docs, npx husky add .husky/pre-commit "npm test" does not seem to be working for me. Throws error for husky.

My husky does not seem to be running at all automatically. When i ran pretty-quick manually, it runs fine. What am i missing here ?

@alexeyten
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants