mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Merge pull request #346 from pre-commit/terminal_width_windows
Support terminal width on windows. Resolves #199
This commit is contained in:
commit
d699f64de8
2 changed files with 5 additions and 16 deletions
|
|
@ -1,27 +1,15 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from backports.shutil_get_terminal_size import get_terminal_size
|
||||||
|
|
||||||
from pre_commit import color
|
from pre_commit import color
|
||||||
from pre_commit import five
|
from pre_commit import five
|
||||||
|
|
||||||
|
|
||||||
# TODO: smell: import side-effects
|
# TODO: smell: import side-effects
|
||||||
try:
|
# TODO: https://github.com/chrippa/backports.shutil_get_terminal_size/issues/4
|
||||||
if not os.environ.get('TERM'): # pragma: no cover (dumb terminal)
|
COLS = get_terminal_size().columns or 80
|
||||||
raise OSError('Cannot determine width without TERM')
|
|
||||||
else: # pragma no cover (windows)
|
|
||||||
COLS = int(
|
|
||||||
subprocess.Popen(
|
|
||||||
('tput', 'cols'), stdout=subprocess.PIPE,
|
|
||||||
).communicate()[0] or
|
|
||||||
# Default in the case of no terminal
|
|
||||||
80
|
|
||||||
)
|
|
||||||
except OSError: # pragma: no cover (windows)
|
|
||||||
COLS = 80
|
|
||||||
|
|
||||||
|
|
||||||
def get_hook_message(
|
def get_hook_message(
|
||||||
|
|
|
||||||
1
setup.py
1
setup.py
|
|
@ -41,6 +41,7 @@ setup(
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'argparse',
|
'argparse',
|
||||||
'aspy.yaml',
|
'aspy.yaml',
|
||||||
|
'backports.shutil_get_terminal_size',
|
||||||
'cached-property',
|
'cached-property',
|
||||||
'jsonschema',
|
'jsonschema',
|
||||||
'nodeenv>=0.11.1',
|
'nodeenv>=0.11.1',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue