UNPKG

3.34 kBMarkdownView Raw
1# husky
2
3> Git hooks made easy
4
5[![](https://img.shields.io/npm/dm/husky.svg?style=flat)](https://www.npmjs.org/package/husky) [![Mac/Linux Build Status](https://img.shields.io/travis/typicode/husky.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/typicode/husky) [![Windows Build status](https://img.shields.io/appveyor/ci/typicode/husky/master.svg?label=Windows)](https://ci.appveyor.com/project/typicode/husky)
6
7Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_
8
9## Support
10
11If Husky is saving you (or your team) time, please consider supporting it on Patreon 👍 thank you!
12
13<p>
14 <a href="https://www.patreon.com/bePatron?c=784328">
15 <img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
16 </a>
17</p>
18
19## Sponsors
20
21<p>
22 <a href="https://patreon.com/typicode">Support Husky and be the first to have your company logo here ;)</a>
23</p>
24
25## Install
26
27```sh
28npm install husky --save-dev
29```
30
31```js
32// package.json
33{
34 "husky": {
35 "hooks": {
36 "pre-commit": "npm test",
37 "pre-push": "npm test",
38 "...": "..."
39 }
40 }
41}
42```
43
44```sh
45git commit -m 'Keep calm and commit'
46```
47
48To go further, see the docs [here](https://github.com/typicode/husky/blob/master/DOCS.md).
49
50__Note__: there's a known issue with Node `v12.0`, please use `v12.1` or higher.
51
52## Uninstall
53
54```sh
55npm uninstall husky
56```
57
58## Upgrading from 0.14
59
60Simply move your existing hooks to `husky.hooks` field and use raw Git hooks names. Also, if you're using the `GIT_PARAMS` env variable, rename it to `HUSKY_GIT_PARAMS`.
61
62```diff
63{
64 "scripts": {
65- "precommit": "npm test",
66- "commitmsg": "commitlint -E GIT_PARAMS"
67 },
68+ "husky": {
69+ "hooks": {
70+ "pre-commit": "npm test",
71+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
72+ }
73+ }
74}
75```
76
77Alternatively, you can run the following command which will do the same automatically for you ;)
78
79```
80./node_modules/.bin/husky-upgrade
81```
82
83Starting with `1.0.0`, you can also configure hooks using `.huskyrc`, `.huskyrc.json` or `.huskyrc.js` file.
84
85```js
86// .huskyrc
87{
88 "hooks": {
89 "pre-commit": "npm test"
90 }
91}
92```
93
94To view the full list of changes, please see the [CHANGELOG](https://github.com/typicode/husky/blob/master/CHANGELOG.md).
95
96## Features
97
98* Keeps existing user hooks
99* Supports GUI Git clients
100* Supports all Git hooks (`pre-commit`, `pre-push`, ...)
101
102## Used by
103
104* [jQuery](https://github.com/jquery/jquery)
105* [babel](https://github.com/babel/babel)
106* [create-react-app](https://github.com/facebookincubator/create-react-app)
107* [Next.js](https://github.com/zeit/next.js)
108* [Hyper](https://github.com/zeit/hyper)
109* [Kibana](https://github.com/elastic/kibana)
110* [JSON Server](https://github.com/typicode/json-server)
111* [Hotel](https://github.com/typicode/hotel)
112* ... and 28k+ [other awesome repos](https://libraries.io/npm/husky/dependent-repositories)
113
114## See also
115
116* [pkg-ok](https://github.com/typicode/pkg-ok) - Prevents publishing a module with bad paths or incorrect line endings
117* [please-upgrade-node](https://github.com/typicode/please-upgrade-node) - Show a message to upgrade Node instead of a stacktrace in your CLIs
118* [pinst](https://github.com/typicode/pinst) - dev only postinstall hook
119
120## License
121
122MIT
123
124[Patreon](https://www.patreon.com/typicode) - [Supporters](https://thanks.typicode.com) ✨