Ver código fonte

disable path if no composer available, fixes #4101

gracefully remove the option and continue, after informing the user
Rob Bast 9 anos atrás
pai
commit
7a50225389
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      src/Composer/Command/ShowCommand.php

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

@@ -197,6 +197,12 @@ EOT
                 }
 
                 $writePath = !$input->getOption('name-only') && $input->getOption('path');
+
+                if ($writePath && null === $composer) {
+                    $this->getIO()->writeError('No composer.json found in the current directory, disabling "path" option');
+                    $writePath = false;
+                }
+
                 $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion && ($nameLength + $versionLength + 3 <= $width);
                 $writeDescription = !$input->getOption('name-only') && !$input->getOption('path') && ($nameLength + ($showVersion ? $versionLength : 0) + 24 <= $width);
                 foreach ($packages[$type] as $package) {