Enable FORCE_COLOR and NO_COLOR for terminal colouring

This commit is contained in:
Hugo van Kemenade 2022-03-12 14:30:35 +02:00
parent b3812f72a9
commit 2a700cf8e5

View File

@ -57,9 +57,13 @@ def term_width_line(text: str) -> str:
def color_terminal() -> bool:
if 'NO_COLOR' in os.environ:
return False
if sys.platform == 'win32' and colorama is not None:
colorama.init()
return True
if 'FORCE_COLOR' in os.environ:
return True
if not hasattr(sys.stdout, 'isatty'):
return False
if not sys.stdout.isatty():