Respect the NO_COLOR environment variable to disable colour.

This commit is contained in:
Bryan Gardiner 2023-05-28 10:09:14 -07:00
parent 19a6f7d3d1
commit 1276c2d3eb
No known key found for this signature in database
GPG key ID: 53EFBCA063E6183C
2 changed files with 7 additions and 1 deletions

View file

@ -2,6 +2,10 @@
## 0.2.4 (unreleased)
- Respect the `NO_COLOR` environment variable and disable colour when it is set
and nonempty (when the default `--color=auto` is used). For more info see:
https://no-color.org
## 0.2.3 (2023-05-22)
- Fix compatibility with nix-2.3 where `nix --extra-experimental-features` isn't

View file

@ -764,7 +764,9 @@ def main():
args = parse_args()
action = args.action
NIX_BIN_DIR = args.nix_bin_dir or None
USE_COLOUR = args.color == "always" or (args.color == "auto" and sys.stdout.isatty())
USE_COLOUR = \
args.color == "always" \
or (args.color == "auto" and sys.stdout.isatty() and not os.getenv('NO_COLOR'))
del args.action
del args.nix_bin_dir
del args.color