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
+15-21Lines changed: 15 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -244,12 +244,25 @@ HUSKY=0 git push # yolo!
244
244
245
245
## Disable husky in CI/Docker
246
246
247
+
There's no right or wrong way to disable husky in CI/Docker context and it's highly dependent on your use-case.
248
+
249
+
### With npm
250
+
247
251
If you want to prevent husky from installing completely
248
252
249
253
```shell
250
254
npm ci --only=production --ignore-scripts
251
255
```
252
256
257
+
Alternatively, you can specifically disable `prepare` script with
258
+
259
+
```shell
260
+
npm set-script prepare ""
261
+
npm ci --only-production
262
+
```
263
+
264
+
### With env variables
265
+
253
266
You can set `HUSKY` environment variable to `0` in your CI config file, to disable all hooks.
254
267
255
268
Alternatively, most Continuous Integration Servers set a `CI` environment variable. You can use it in your hooks to detect if it's running in a CI.
@@ -260,6 +273,8 @@ Alternatively, most Continuous Integration Servers set a `CI` environment variab
260
273
[ -n"$CI" ] &&exit 0
261
274
```
262
275
276
+
### With is-ci
277
+
263
278
You can also use [is-ci](https://github.com/watson/is-ci) in your `prepare` script to conditionally install husky
264
279
265
280
```shell
@@ -304,27 +319,6 @@ To **revert** the git-flow hooks directory back to its default you need to reset
304
319
git config gitflow.path.hooks .git/hooks
305
320
```
306
321
307
-
## Sharing hooks
308
-
309
-
Most of the time, a better approach is to create shareable configs for the tools you're using. However if you need to share hook scripts using npm, you can do so this way:
0 commit comments