1 | # Announcement: Husky is on [Open Collective](https://opencollective.com/husky) 🎉
|
2 |
|
3 | ---
|
4 |
|
5 | # Husky
|
6 |
|
7 | [![Financial Contributors on Open Collective](https://opencollective.com/husky/all/badge.svg?label=financial+contributors)](https://opencollective.com/husky) [![](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)
|
8 |
|
9 | > Git hooks made easy
|
10 |
|
11 | Husky can prevent bad `git commit`, `git push` and more 🐶 _woof!_
|
12 |
|
13 | ## Install
|
14 |
|
15 | ```sh
|
16 | npm install husky --save-dev
|
17 | ```
|
18 |
|
19 | ```js
|
20 | // package.json
|
21 | {
|
22 | "husky": {
|
23 | "hooks": {
|
24 | "pre-commit": "npm test",
|
25 | "pre-push": "npm test",
|
26 | "...": "..."
|
27 | }
|
28 | }
|
29 | }
|
30 | ```
|
31 |
|
32 | ```sh
|
33 | git commit -m 'Keep calm and commit'
|
34 | ```
|
35 |
|
36 | To go further, see the docs [here](https://github.com/typicode/husky/blob/master/DOCS.md).
|
37 |
|
38 | __Note__: there's a known issue with Node `v12.0`, please use `v12.1` or higher.
|
39 |
|
40 | ## Uninstall
|
41 |
|
42 | ```sh
|
43 | npm uninstall husky
|
44 | ```
|
45 |
|
46 | Git hooks installed by husky will be removed.
|
47 |
|
48 | ## Financial Contributors
|
49 |
|
50 | Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/husky/contribute)]
|
51 |
|
52 | ### Individuals
|
53 |
|
54 | <a href="https://opencollective.com/husky"><img src="https://opencollective.com/husky/individuals.svg?width=890"></a>
|
55 |
|
56 | ### Organizations
|
57 |
|
58 | Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/husky/contribute)]
|
59 |
|
60 | <a href="https://opencollective.com/husky/organization/0/website"><img src="https://opencollective.com/husky/organization/0/avatar.svg"></a>
|
61 | <a href="https://opencollective.com/husky/organization/1/website"><img src="https://opencollective.com/husky/organization/1/avatar.svg"></a>
|
62 | <a href="https://opencollective.com/husky/organization/2/website"><img src="https://opencollective.com/husky/organization/2/avatar.svg"></a>
|
63 | <a href="https://opencollective.com/husky/organization/3/website"><img src="https://opencollective.com/husky/organization/3/avatar.svg"></a>
|
64 | <a href="https://opencollective.com/husky/organization/4/website"><img src="https://opencollective.com/husky/organization/4/avatar.svg"></a>
|
65 | <a href="https://opencollective.com/husky/organization/5/website"><img src="https://opencollective.com/husky/organization/5/avatar.svg"></a>
|
66 | <a href="https://opencollective.com/husky/organization/6/website"><img src="https://opencollective.com/husky/organization/6/avatar.svg"></a>
|
67 | <a href="https://opencollective.com/husky/organization/7/website"><img src="https://opencollective.com/husky/organization/7/avatar.svg"></a>
|
68 | <a href="https://opencollective.com/husky/organization/8/website"><img src="https://opencollective.com/husky/organization/8/avatar.svg"></a>
|
69 | <a href="https://opencollective.com/husky/organization/9/website"><img src="https://opencollective.com/husky/organization/9/avatar.svg"></a>
|
70 |
|
71 |
|
72 | ## Upgrading from 0.14
|
73 |
|
74 | Simply 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`.
|
75 |
|
76 | ```diff
|
77 | {
|
78 | "scripts": {
|
79 | - "precommit": "npm test",
|
80 | - "commitmsg": "commitlint -E GIT_PARAMS"
|
81 | },
|
82 | + "husky": {
|
83 | + "hooks": {
|
84 | + "pre-commit": "npm test",
|
85 | + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
|
86 | + }
|
87 | + }
|
88 | }
|
89 | ```
|
90 |
|
91 | Alternatively, you can run the following command which will do the same automatically for you ;)
|
92 |
|
93 | ```
|
94 | ./node_modules/.bin/husky-upgrade
|
95 | ```
|
96 |
|
97 | Starting with `1.0.0`, you can also configure hooks using `.huskyrc`, `.huskyrc.json` or `.huskyrc.js` file.
|
98 |
|
99 | ```js
|
100 | // .huskyrc
|
101 | {
|
102 | "hooks": {
|
103 | "pre-commit": "npm test"
|
104 | }
|
105 | }
|
106 | ```
|
107 |
|
108 | To view the full list of changes, please see the [CHANGELOG](https://github.com/typicode/husky/blob/master/CHANGELOG.md).
|
109 |
|
110 | ## Features
|
111 |
|
112 | * Keeps existing user hooks
|
113 | * Supports GUI Git clients
|
114 | * Supports all Git hooks (`pre-commit`, `pre-push`, ...)
|
115 |
|
116 | ## Used by
|
117 |
|
118 | * [webpack](https://github.com/webpack/webpack)
|
119 | * [babel](https://github.com/babel/babel)
|
120 | * [create-react-app](https://github.com/facebookincubator/create-react-app)
|
121 | * [Next.js](https://github.com/zeit/next.js)
|
122 | * [Hyper](https://github.com/zeit/hyper)
|
123 | * [Kibana](https://github.com/elastic/kibana)
|
124 | * [JSON Server](https://github.com/typicode/json-server)
|
125 | * [Hotel](https://github.com/typicode/hotel)
|
126 | * ... and many other awesome projects
|
127 |
|
128 | ## See also
|
129 |
|
130 | * [pkg-ok](https://github.com/typicode/pkg-ok) - Prevents publishing a module with bad paths or incorrect line endings
|
131 | * [please-upgrade-node](https://github.com/typicode/please-upgrade-node) - Show a message to upgrade Node instead of a stacktrace in your CLIs
|
132 | * [pinst](https://github.com/typicode/pinst) - dev only postinstall hook
|
133 |
|
134 | ### Patreon
|
135 |
|
136 | People and companies supporting via Patreon: [thanks](https://thanks.typicode.com)
|
137 |
|
138 | ## License
|
139 |
|
140 | MIT
|