There was an error while loading. Please reload this page.
1 parent a970d3b commit 3d777bbCopy full SHA for 3d777bb
1 file changed
pre_commit/color.py
@@ -3,13 +3,13 @@
3
import os
4
import sys
5
6
-terminal_supports_colors = True
+terminal_supports_color = True
7
if os.name == 'nt': # pragma: no cover (windows)
8
from pre_commit.color_windows import enable_virtual_terminal_processing
9
try:
10
enable_virtual_terminal_processing()
11
except WindowsError:
12
- terminal_supports_colors = False
+ terminal_supports_color = False
13
14
RED = '\033[41m'
15
GREEN = '\033[42m'
@@ -30,7 +30,7 @@ def format_color(text, color, use_color_setting):
30
color - The color start string
31
use_color_setting - Whether or not to color
32
"""
33
- if not use_color_setting or not terminal_supports_colors:
+ if not use_color_setting:
34
return text
35
else:
36
return '{}{}{}'.format(color, text, NORMAL)
@@ -48,4 +48,7 @@ def use_color(setting):
48
if setting not in COLOR_CHOICES:
49
raise InvalidColorSetting(setting)
50
51
- return setting == 'always' or (setting == 'auto' and sys.stdout.isatty())
+ return (
52
+ setting == 'always' or
53
+ (setting == 'auto' and sys.stdout.isatty() and terminal_supports_color)
54
+ )
0 commit comments