Skip to content

Commit 2917a94

Browse files
committed
docs: update Docker section
1 parent 1c46e27 commit 2917a94

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

docs/README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,25 @@ HUSKY=0 git push # yolo!
244244

245245
## Disable husky in CI/Docker
246246

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+
247251
If you want to prevent husky from installing completely
248252

249253
```shell
250254
npm ci --only=production --ignore-scripts
251255
```
252256

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+
253266
You can set `HUSKY` environment variable to `0` in your CI config file, to disable all hooks.
254267

255268
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
260273
[ -n "$CI" ] && exit 0
261274
```
262275

276+
### With is-ci
277+
263278
You can also use [is-ci](https://github.com/watson/is-ci) in your `prepare` script to conditionally install husky
264279

265280
```shell
@@ -304,27 +319,6 @@ To **revert** the git-flow hooks directory back to its default you need to reset
304319
git config gitflow.path.hooks .git/hooks
305320
```
306321

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:
310-
311-
```
312-
// my-husky-scripts/index.js
313-
module.exports = {
314-
'pre-commit': 'echo hello'
315-
}
316-
```
317-
318-
```
319-
npm install my-husky-scripts --save-dev
320-
```
321-
322-
```sh
323-
# .husky/pre-commit
324-
# ...
325-
eval "$(node -p "require('my-husky-scripts')['pre-commit']")"
326-
```
327-
328322
# FAQ
329323

330324
## Does it work on Windows?

0 commit comments

Comments
 (0)