mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-15 18:11:48 +04:00
Add support for passing cwd and env to xargs
This commit is contained in:
parent
a18b683d12
commit
24a2c3d8db
1 changed files with 3 additions and 2 deletions
|
|
@ -109,6 +109,7 @@ def xargs(cmd, varargs, **kwargs):
|
||||||
"""
|
"""
|
||||||
negate = kwargs.pop('negate', False)
|
negate = kwargs.pop('negate', False)
|
||||||
target_concurrency = kwargs.pop('target_concurrency', 1)
|
target_concurrency = kwargs.pop('target_concurrency', 1)
|
||||||
|
max_length = kwargs.pop('_max_length', _get_platform_max_length())
|
||||||
retcode = 0
|
retcode = 0
|
||||||
stdout = b''
|
stdout = b''
|
||||||
stderr = b''
|
stderr = b''
|
||||||
|
|
@ -118,10 +119,10 @@ def xargs(cmd, varargs, **kwargs):
|
||||||
except parse_shebang.ExecutableNotFoundError as e:
|
except parse_shebang.ExecutableNotFoundError as e:
|
||||||
return e.to_output()
|
return e.to_output()
|
||||||
|
|
||||||
partitions = partition(cmd, varargs, target_concurrency, **kwargs)
|
partitions = partition(cmd, varargs, target_concurrency, max_length)
|
||||||
|
|
||||||
def run_cmd_partition(run_cmd):
|
def run_cmd_partition(run_cmd):
|
||||||
return cmd_output(*run_cmd, encoding=None, retcode=None)
|
return cmd_output(*run_cmd, encoding=None, retcode=None, **kwargs)
|
||||||
|
|
||||||
threads = min(len(partitions), target_concurrency)
|
threads = min(len(partitions), target_concurrency)
|
||||||
with _thread_mapper(threads) as thread_map:
|
with _thread_mapper(threads) as thread_map:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue