Преглед изворни кода

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

Jordi Boggiano пре 8 година
родитељ
комит
d6ffe1fd1d
2 измењених фајлова са 10 додато и 4 уклоњено
  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
 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
   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

+ 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);
                 $writeLatest = $writeVersion && $showLatest && ($nameLength + $versionLength + $latestLength + 3 <= $width);
                 $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + $versionLength + $latestLength + 24 <= $width);
+                if ($writeLatest && !$io->isDecorated()) {
+                    $latestLength += 2;
+                }
                 $hasOutdatedPackages = false;
                 foreach ($packages[$type] as $package) {
                     if (is_object($package)) {
@@ -339,6 +342,9 @@ EOT
                         if ($writeLatest && $latestPackackage) {
                             $latestVersion = $latestPackackage->getFullPrettyVersion();
                             $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);
                         }