From 80450dc5a7dfa93365f78b0f5882e30a676bc6a7 Mon Sep 17 00:00:00 2001 From: typicode Date: Tue, 6 Jul 2021 12:06:00 +0200 Subject: [PATCH] docs: update Docker section --- docs/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index cf1b835d4..d01d7d9c8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -244,7 +244,7 @@ HUSKY=0 git push # yolo! ## Disable husky in CI/Docker -There's no right or wrong way to disable husky in CI/Docker context and it's highly dependent on your use-case. +There's no right or wrong way to disable husky in CI/Docker context and is highly __dependent on your use-case__. ### With npm @@ -261,6 +261,22 @@ npm set-script prepare "" npm ci --only-production ``` +### With a custom script + +You can create a custom JS script and conditionally require husky and install hooks. + +```json +"prepare": "node ./prepare.js" +``` + +```js +// prepare.js +const someConditions = process.env.CI !== undefined +if (someConditions) { + require('husky').install() +} +``` + ### With env variables You can set `HUSKY` environment variable to `0` in your CI config file, to disable all hooks.