Merge pull request #4477 from mfn/mfn-console-output-isatty

console: don't use colored output if there's no TTY
This commit is contained in:
Mark Story 2014-09-03 07:55:15 -04:00
commit ee1e2705a2
2 changed files with 8 additions and 2 deletions

View file

@ -161,7 +161,10 @@ class ConsoleOutput {
public function __construct($stream = 'php://stdout') {
$this->_output = fopen($stream, 'w');
if (DS === '\\' && !(bool)env('ANSICON')) {
if (
(DS === '\\' && !(bool)env('ANSICON')) ||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
) {
$this->_outputAs = self::PLAIN;
}
}

View file

@ -48,7 +48,10 @@ class ConsoleLog extends BaseLog {
*/
public function __construct($config = array()) {
parent::__construct($config);
if (DS === '\\' && !(bool)env('ANSICON')) {
if (
(DS === '\\' && !(bool)env('ANSICON')) ||
(function_exists('posix_isatty') && !posix_isatty($this->_output))
) {
$outputAs = ConsoleOutput::PLAIN;
} else {
$outputAs = ConsoleOutput::COLOR;