mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-17 22:40:11 -06:00
show color in hook outputs when attached to a tty
This commit is contained in:
@@ -13,6 +13,7 @@ import six
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
from pre_commit.util import cmd_output_b
|
||||
from pre_commit.util import cmd_output_p
|
||||
|
||||
|
||||
def _environ_size(_env=None):
|
||||
@@ -108,9 +109,11 @@ def xargs(cmd, varargs, **kwargs):
|
||||
negate: Make nonzero successful and zero a failure
|
||||
target_concurrency: Target number of partitions to run concurrently
|
||||
"""
|
||||
color = kwargs.pop('color', False)
|
||||
negate = kwargs.pop('negate', False)
|
||||
target_concurrency = kwargs.pop('target_concurrency', 1)
|
||||
max_length = kwargs.pop('_max_length', _get_platform_max_length())
|
||||
cmd_fn = cmd_output_p if color else cmd_output_b
|
||||
retcode = 0
|
||||
stdout = b''
|
||||
|
||||
@@ -122,7 +125,7 @@ def xargs(cmd, varargs, **kwargs):
|
||||
partitions = partition(cmd, varargs, target_concurrency, max_length)
|
||||
|
||||
def run_cmd_partition(run_cmd):
|
||||
return cmd_output_b(
|
||||
return cmd_fn(
|
||||
*run_cmd, retcode=None, stderr=subprocess.STDOUT, **kwargs
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user