Merge pull request #7 from zhamao-robot/fix-no-terminal-size-without-io

修復无交互环境下无法获取终端尺寸
This commit is contained in:
sunxyw 2023-03-09 23:41:10 +08:00 committed by GitHub
commit 1b7e343493
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -10,7 +10,7 @@ use Psr\Log\LogLevel;
class ConsoleLogger extends AbstractLogger
{
public const VERSION = '1.1.0';
public const VERSION = '1.1.1';
/**
* 日志输出格式

View File

@ -237,7 +237,12 @@ class TablePrinter
}
} else {
$size = exec('stty size 2>/dev/null');
$size = (int) explode(' ', trim($size))[1];
// in case stty is not available
if (empty($size)) {
$size = 0;
} else {
$size = (int) explode(' ', trim($size))[1];
}
}
if (empty($size)) {
return $this->terminal_size = 79;