Assume infinite terminal width when not running in a terminal

Close https://github.com/docker/compose/issues/7119

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-01-06 17:25:25 +01:00
parent e9220f45df
commit 3df4ba1544
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 6 additions and 1 deletions

View File

@ -17,7 +17,12 @@ else:
def get_tty_width():
try:
width, _ = get_terminal_size()
# get_terminal_size can't determine the size if compose is piped
# to another command. But in such case it doesn't make sense to
# try format the output by terminal size as this output is consumed
# by another command. So let's pretend we have a huge terminal so
# output is single-lined
width, _ = get_terminal_size(fallback=(999, 0))
return int(width)
except OSError:
return 0