You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/README.md
+48-23Lines changed: 48 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,23 +26,17 @@ Already using husky? See [Migrate from 4 to 5](https://typicode.github.io/husky/
26
26
## Automatic (recommended)
27
27
28
28
```shell
29
-
# npm
30
29
npm install husky --save-dev && npx husky init
31
-
32
-
# yarn
33
-
yarn add husky --dev && yarn husky init
34
30
```
35
31
36
-
The command above will setup husky and create a sample `pre-commit` hook that you can edit. By default, it will run `npm test` when you commit.
32
+
The command above will setup husky, modify `package.json` and create a sample `pre-commit` hook that you can edit. By default, it will run `npm test` when you commit.
3. To automatically have Git hooks enabled after install, edit `package.json`
@@ -80,6 +66,8 @@ yarn husky install
80
66
}
81
67
```
82
68
69
+
!> **Yarn v2 doesn't support `prepare` lifecycle script, so husky needs to be installed differently (this doesn't apply to yarn v1 though). See [Yarn v2 install](/?id=yarn-v2).**
70
+
83
71
### Add a hook
84
72
85
73
To add a hook, use `husky add <file> [cmd]` (don't forget to run `husky install` before).
@@ -98,17 +86,54 @@ If `npm test` command fails, your commit will be automatically aborted.
98
86
99
87
!> **Using Yarn to run commands? There's an issue on Windows with Git Bash, see [Yarn on Windows](#/?id=yarn-on-windows).**
100
88
101
-
## Uninstall
89
+
###Uninstall
102
90
103
91
```shell
104
-
# npm
105
92
npm uninstall husky
93
+
```
94
+
95
+
## Yarn v2
96
+
97
+
### Install
98
+
99
+
1. Install `husky`
100
+
101
+
```shell
102
+
yarn install husky --save-dev
103
+
yarn add pinst --dev # if your package is not private
104
+
```
105
+
106
+
2. Enable Git hooks
107
+
108
+
```shell
109
+
yarn husky install
110
+
```
111
+
112
+
3. To automatically have Git hooks enabled after install, edit `package.json`
**Note:** When uninstalling with npm, `git config --unset core.hooksPath` will be automatically run for you.
124
+
!> **if your package is not private and you're publishing it on a registry like [npmjs.com](https://npmjs.com), you need to disable `postinstall` script using [pinst](https://github.com/typicode/pinst)**. Otherwise, `postinstall` will run when someone installs your package and result in an error.
0 commit comments