Skip to content

Commit

Permalink
only enable colors when output to a terminal (not to a file)
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Oct 6, 2014
1 parent 1695564 commit 591efd8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/TextUI/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,11 @@ protected function handleArguments(array $argv)

foreach ($this->options[0] as $option) {
switch ($option[0]) {
case '--colors': {
$this->arguments['colors'] = true;
case '--colors':
if (function_exists("posix_isatty") && !posix_isatty(STDOUT)) {
$this->arguments['colors'] = false;
} else {
$this->arguments['colors'] = true;
}
break;

Expand Down
3 changes: 3 additions & 0 deletions src/Util/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ public function getPHPUnitConfiguration()
$result['colors'] = $this->getBoolean(
(string) $root->getAttribute('colors'), false
);
if ($result['colors'] && function_exists("posix_isatty") && !posix_isatty(STDOUT)) {
$result['colors'] = false;
}
}

/**
Expand Down

0 comments on commit 591efd8

Please sign in to comment.