toplenboren / simple-git-hooks

A simple git hooks manager for small projects
MIT License
1.24k stars 37 forks source link

Use simple-git-hooks as api? #108

Open mmunte-impeo opened 3 months ago

mmunte-impeo commented 3 months ago

Hello

is it possible to use the simple-git-hooks as a library/api?

I would like to detect and react to branch changes on a watch mode build script (using esbuild and typechecking).

In case of branch changes, sometimes incremental builds and typechecks do not work reliably, so I would restart those. But for this i need to detect git hooks as an event/callback.

Thx!

toplenboren commented 3 months ago

Hello!

Don't really think how utilising git-hooks might help you.

In a nutshell git hook is simply an .sh script that runs sometime and will fail if returned with non-zero code. I'd have resorted to custom .sh scripts for that cause

In any case, here is some info that might help you:

simple-git-hooks is just a wrapper behind git hooks. simple-git-hooks.js has exportable methods for setting/removing hooks, finding package.json or finding git root. Please check out how the simple-git-hooks.test.js are written, they import these methods form simple-git-hooks file

You might want to opt out of automatically installing git hooks to your system by using SKIP_INSTALL_SIMPLE_GIT_HOOKS=1 environment variable.