Skip to content

nikoladavitkovski/husky

 
 

Repository files navigation

husky

Open Collective Node.js CI

Modern native Git hooks made easy

Husky improves your commits and more 🐶 woof!

Install

Easy install (reccomended)

husky-init is a one-time command to configure a project with husky.

It installs husky into your project and auto-configures your package.json, ensuring that every time you run yarn|npm install git is then configured to use your hooks (so you don't have to worry about it again).

npx husky-init && npm install       # npm
npx husky-init && yarn              # Yarn 1
yarn dlx husky-init --yarn2 && yarn # Yarn 2+
pnpm dlx husky-init && pnpm install # pnpm

It will:

  • install husky
  • modify package.json (adding a prepare script)
  • create a sample pre-commit hook that you can edit. By default this runs npm test when you commit.

Manual Install

  1. Install husky
npm install husky --save-dev
yarn add --dev husky
  1. Enable Git hooks
npx husky install # will configure git to use .husky/ by default
  1. To automatically have Git hooks enabled after every npm/yarn install, edit package.json to use one of the npm/yarm lifecyle hooks e.g. prepare.
npm set-script prepare "husky install"

You should have:

// package.json
{
  "scripts": {
    "prepare": "husky install"
  }
}

Documentation

https://typicode.github.io/husky

Important Upgrading from v4 to v7 requires migrating previous config, please see the docs.

Articles

License

MIT

Sponsors

Companies

Does your company use husky? Ask your manager or marketing team if your company would be interested in supporting this project.

Individuals

Find husky helpful? Become a backer and show your appreciation with a monthly donation on Open Collective. You can also tip with a one-time donation.

GitHub sponsors can be viewed on my profile. All past and current Open Collective sponsors can be viewed on here.

Packages

No packages published

Languages

  • JavaScript 99.0%
  • Shell 1.0%