Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simple-git-hooks as api? #108

Open
mmunte-impeo opened this issue Mar 31, 2024 · 1 comment
Open

Use simple-git-hooks as api? #108

mmunte-impeo opened this issue Mar 31, 2024 · 1 comment

Comments

@mmunte-impeo
Copy link

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants