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

Allow hook commands to be reused #911

Open
laura-turner-evolvemep opened this issue Jan 6, 2025 · 0 comments
Open

Allow hook commands to be reused #911

laura-turner-evolvemep opened this issue Jan 6, 2025 · 0 comments
Labels
feature request A new lefthook feature description

Comments

@laura-turner-evolvemep
Copy link

laura-turner-evolvemep commented Jan 6, 2025

⚡ Summary

It would be useful to reuse a hook command across multiple hooks. For example, using the same command across both post-checkout and post-merge.

Value

Some hooks need to run the same commands; copy and pasting these commands is more error prone, especially if these commands need to be changed in the future.

Behavior and configuration changes

A way I've though of changing this is to be able to define a top-level commands map in lefthook.yml, and then be able to reference it in my hooks. For example:

Current config (simplified)

post-merge:
  commands:
    install-packages:
      run: yarn

post-checkout:
  commands:
    install-packages:
      run: yarn

Updated config

post-merge:
  commands:
    install-packages

post-checkout:
  commands:
    install-packages

commands:
  install-packages:
    run: yarn
@laura-turner-evolvemep laura-turner-evolvemep added the feature request A new lefthook feature description label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

1 participant