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

Mapping conditions to specific hook(s) only #41

Open
brettz9 opened this issue Aug 5, 2020 · 1 comment
Open

Mapping conditions to specific hook(s) only #41

brettz9 opened this issue Aug 5, 2020 · 1 comment

Comments

@brettz9
Copy link

brettz9 commented Aug 5, 2020

Hi,

This appears to be an extremely useful tool--should be built into npm!

One feature request if I may...

I'd like for some file change conditions to only apply for certain hooks.

For example, I have some pre-commit hooks to run to ensure repo-bundled build files get updated (they are bundled so that GitHub Pages will have access to them), but I don't want such time-consuming scripts running for everyone on the team upon a merge hook since their pulls should already receive the updated build files as they would already have been updated in the commit history.

However, I have other hooks I do want run on checkout since they are not repo-bundled, e.g., dev. documentation and npm dependencies.

(I thought of using lint-staged for the repo-bundled changes, but that passes on arguments to my scripts which I don't want to occur in these cases, e.g., for npm-run-all, which may give errors upon receiving extra arguments.)

If this is not already possible to implement, might you consider allowing more fine-grained control of which hook (or hooks) are run for which conditions?

@hkdobrev
Copy link
Owner

I could implement this after Git introduces an environment variable for which hook ran a script. Depends on git/git#1271

Husky also doesn't offer a way to see which hook ran.

I could add an option flag for this, but doesn't seem to be such a high necessity to warrant a new option for target. Instead, I'd prefer to keep to using the upcoming environment variable from Git itself and expanding the config with patterns.

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