Skip to content

Commit

Permalink
Merge pull request #7 from zhamao-robot/fix-no-terminal-size-without-io
Browse files Browse the repository at this point in the history
修復无交互环境下无法获取终端尺寸
  • Loading branch information
sunxyw committed Mar 9, 2023
2 parents 5158a0e + 97ee152 commit 1b7e343
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ZM/Logger/ConsoleLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ConsoleLogger extends AbstractLogger
{
public const VERSION = '1.1.0';
public const VERSION = '1.1.1';

/**
* 日志输出格式
Expand Down
7 changes: 6 additions & 1 deletion src/ZM/Logger/TablePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,12 @@ public function fetchTerminalSize(): int
}
} 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;
Expand Down

0 comments on commit 1b7e343

Please sign in to comment.