-
Notifications
You must be signed in to change notification settings - Fork 0
Remove color if not tty #3
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |
|
|
||
| ## [Unreleased] | ||
|
|
||
| - Add option to disable color with environment variable "NO_COLOR" | ||
| - Default coloring to true if $stdout is terminal | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. documenting this in the README too would be nice |
||
|
|
||
| ## [0.3.0] - 2024-04-16 | ||
|
|
||
| ### Changed | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ GEM | |
| unicode-display_width (2.5.0) | ||
|
|
||
| PLATFORMS | ||
| arm64-darwin-22 | ||
| x86_64-linux | ||
|
|
||
| DEPENDENCIES | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,20 @@ class << self | |
| attr_reader :config | ||
| end | ||
|
|
||
| DEFAULT = Config.new(colorize: true).freeze | ||
| @config = DEFAULT.dup | ||
| # Generates the default configuration | ||
| def self.default_configuration | ||
| config = Config.new(colorize: true) | ||
|
|
||
| if !ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider a spec for this (in it might be unexpected that NO_COLOR=0 sets color to |
||
| config.colorize = false | ||
| else | ||
| config.colorize = $stdout.isatty | ||
| end | ||
|
|
||
| config.freeze | ||
| end | ||
|
|
||
| @config = default_configuration.dup | ||
|
|
||
| # private, used for testing | ||
| def self._set_config(new_config) | ||
|
|
@@ -22,9 +34,4 @@ def self.configure | |
| yield(@config) | ||
| @config | ||
| end | ||
|
|
||
| # Generates the default configuration | ||
| def self.default_configuration | ||
| DEFAULT | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should be under a
### Addedheading while the next should be under### Changedreview the keep a changelog link at the top