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

feat: disable colored output if NO_COLOR is defined #40

Merged
merged 8 commits into from
Dec 25, 2023
Merged

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented Dec 23, 2023

This is a rebase of ddollar#124 by @sehrope

This PR is a rebased version of ddollar#122 with a couple more commits added by me. That original PR improves the error handling and adds automatic disabling of color output based on whether stdout is a terminal.

This PR expands on that with a few more commits to:

  1. Checks for a NO_COLOR env variable and, if defined, disables color output regardless of whether we're running in a terminal (per https://no-color.org/)
$ NO_COLOR=1 forego start
...
  1. Optimize things a bit by only creating the "left" outlet formatter once. Previously it was being generated for ever line of output but the format itself never changes so it's wasted cycles.

The original PR also included this:

  1. Add injecting a VERSION Makefile variable so you can include the date / commit in the resulting build. Defaults to current value of "dev":
$ make VERSION="$(date --utc +%Y%m%d-%H%M%S)-$(git show-ref -s -- HEAD)" build
...
$ forego version
20200605-120321-0bdbf9b27cf9da13e246ff1ba90ab5961f4be849

Which has been replaced by a similar version injection closer to what we already do in docker-gen.

schwarz-b5c and others added 8 commits December 23, 2023 23:36
There are plenty of environments without BASH, but with sh.
These could have caused problems: $!"\
- exit if directory doesn't exist
- source .profile only if it exists
- don't suppress stderr while doing that
The output padding is based upon the longest name of processes and thus never
changes at runtime so we can optimize things a bit by only creating the output
formatter pattern once at startup.
mirroring what's being done with docker-gen
@buchdag buchdag marked this pull request as draft December 23, 2023 23:05
@buchdag buchdag marked this pull request as ready for review December 25, 2023 19:36
@buchdag buchdag merged commit 30ad9ca into main Dec 25, 2023
1 check passed
@buchdag buchdag deleted the nocolor branch December 25, 2023 19:37
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.

3 participants