-
Notifications
You must be signed in to change notification settings - Fork 220
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
Add option to force colorized output #582
Comments
Hey! There's a config option for that instead – Do you use lefthook in CI? Could you share your use case please? |
I do use (well plan to use) lefthook in CI. Use case is: run exactly same things on developer systems and in CI. Same versions of everything, same config of everything. pre-commit works great for that, but has some other not so great parts that I'd hope lefthook will help fix. Lefthook does not have builtin help for "same versions of everything" e.g. installing things which pre-commit does have (and that's its killer feature), but I have a hatching project at https://github.com/scop/wrun which will help with that in some cases. Some WIP dogfooding using lefthook at scop/wrun#49 -- this same thing runs both in CI and locally. |
Regarding the config option, I guess I could make do with that and set up different config files for CI and local dev, but that's IMO really an antipattern I'd like to avoid having to do by default. In CI we need to invoke lefthook manually, and dropping e.g. |
Regarding CI usage, here's pre-commit's related docs: https://pre-commit.com/#usage-in-continuous-integration In my experience, this use case for pre-commit (and other hook managers) is not at all uncommon, there are lots of repositories e.g. here at GitHub that are set up to run the same hooks locally and in GH Actions. |
I found that the indirect termenv dependency supports CLICOLOR_FORCE for this. I'm not sure if it's equal to forcing all color from lefthook, but it's a good start and enough for me for the time being: https://github.com/muesli/termenv?tab=readme-ov-file#usage Example CI run at https://github.com/scop/wrun/actions/runs/10602871399/job/29385896528 ("Run lefthook pre-commit") If considering implementing direct support for env based color toggles in lefthook, here are the "standards" to look into Currently the said github.com/muesli/termenv and github.com/fatih/color indirect deps have some support for these. |
I've addressed this feature request in the PR #812. Please, review it if you have a chance. |
Sorry, this went unnoticed by me, late thanks! |
⚡ Summary
An option to force colorized output would be nice. For example when running in GitHub Actions, the output is color capable but lefthook does not currently colorize there.
Value
More color and arguably readability in CI logs when lefthook is run there.
Behavior and configuration changes
Would probably be a good idea to deprecate the existing
--no-colors
flag and add a new--color={on,off,auto}
to replace it.The text was updated successfully, but these errors were encountered: