From d12efa2d19dda94b507a4342ac433ae8047b0792 Mon Sep 17 00:00:00 2001 From: typicode Date: Sat, 22 May 2021 07:50:28 +0200 Subject: [PATCH] docs: add sharing hooks recipe --- docs/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/README.md b/docs/README.md index b39828c19..52e1dbee0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -303,6 +303,27 @@ To **revert** the git-flow hooks directory back to its default you need to reset git config gitflow.path.hooks .git/hooks ``` +## Sharing hooks + +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: + +``` +// my-husky-scripts/index.js +module.exports = { + 'pre-commit': 'echo hello' +} +``` + +``` +npm install my-husky-scripts --save-dev +``` + +```sh +# .husky/pre-commit +# ... +eval "$(node -p "require('my-husky-scripts')['pre-commit']")" +``` + # FAQ ## Does it work on Windows?