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

cmd: respect TERM=dumb by not using colors #511

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

acln0
Copy link
Contributor

@acln0 acln0 commented Oct 4, 2022

Description

Check for TERM=dumb when determining whether to use colors when printing.

Fixes #510

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Version of Golang used when building/testing:

  • 1.11
  • 1.12
  • 1.13
  • 1.14
  • 1.15
  • 1.16
  • 1.17
  • 1.18
  • 1.19

How Has This Been Tested?

Per #510, I tested by inspecting the output, which no longer contains colors.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@@ -297,7 +297,7 @@ func getLogger(levelStr string) (zerolog.Logger, error) {
Out: out,
TimeFormat: time.RFC822,
}
if !terminal.IsTerminal(int(out.Fd())) {
if !terminal.IsTerminal(int(out.Fd())) || os.Getenv("TERM") == "dumb" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer this to be pulled in as a config value that can be bound to an env var like MOCKERY_DISABLE_COLORING.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TERM already is an env var -- the right one for this case.

@LandonTClipp LandonTClipp merged commit 94c17ff into vektra:master Oct 31, 2022
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

Successfully merging this pull request may close these issues.

cmd: prints escape sequences for colors in terminals with no color support
3 participants