Browse Source

Add support for outdated command info without ANSI colors, fixes #6070

Jordi Boggiano 8 years ago
parent
commit
d6ffe1fd1d
2 changed files with 10 additions and 4 deletions
  1. 4 4
      src/Composer/Command/OutdatedCommand.php
  2. 6 0
      src/Composer/Command/ShowCommand.php

+ 4 - 4
src/Composer/Command/OutdatedCommand.php

@@ -39,13 +39,13 @@ class OutdatedCommand extends ShowCommand
             ->setHelp(<<<EOT
             ->setHelp(<<<EOT
 The outdated command is just a proxy for `composer show -l`
 The outdated command is just a proxy for `composer show -l`
 
 
-The color coding for dependency versions is as such:
+The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
 
 
-- <info>green</info>: Dependency is in the latest version and is up to date.
-- <comment>yellow</comment>: Dependency has a new version available that includes backwards
+- <info>green</info> (=): Dependency is in the latest version and is up to date.
+- <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
   compatibility breaks according to semver, so upgrade when you can but it
   compatibility breaks according to semver, so upgrade when you can but it
   may involve work.
   may involve work.
-- <highlight>red</highlight>: Dependency has a new version that is semver-compatible and you should upgrade it.
+- <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
 
 
 
 
 EOT
 EOT

+ 6 - 0
src/Composer/Command/ShowCommand.php

@@ -317,6 +317,9 @@ EOT
                 $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width);
                 $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width);
                 $writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width);
                 $writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width);
                 $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width);
                 $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width);
+                if ($writeLatest && !$io->isDecorated()) {
+                    $latestLength += 2;
+                }
                 $hasOutdatedPackages = false;
                 $hasOutdatedPackages = false;
                 foreach ($packages[$type] as $package) {
                 foreach ($packages[$type] as $package) {
                     if (is_object($package)) {
                     if (is_object($package)) {
@@ -339,6 +342,9 @@ EOT
                         if ($writeLatest && $latestPackackage) {
                         if ($writeLatest && $latestPackackage) {
                             $latestVersion = $latestPackackage->getFullPrettyVersion();
                             $latestVersion = $latestPackackage->getFullPrettyVersion();
                             $style = $this->getVersionStyle($latestPackackage, $package);
                             $style = $this->getVersionStyle($latestPackackage, $package);
+                            if (!$io->isDecorated()) {
+                                $latestVersion = str_replace(array('info', 'highlight', 'comment'), array('=', '!', '~'), $style) . ' ' . $latestVersion;
+                            }
                             $io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false);
                             $io->write(' <'.$style.'>' . str_pad($latestVersion, $latestLength, ' ') . '</'.$style.'>', false);
                         }
                         }