From 7a50225389fcb218a483331434143fc4207a322d Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Fri, 5 Jun 2015 13:00:04 +0200 Subject: [PATCH 1/2] disable path if no composer available, fixes #4101 gracefully remove the option and continue, after informing the user --- src/Composer/Command/ShowCommand.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 1ac67c711..7dc691b7b 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/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) { From dfbee6a532ffa36d12f7d5c15d9cd6e0bb0dc08b Mon Sep 17 00:00:00 2001 From: Rob Bast Date: Fri, 5 Jun 2015 13:04:56 +0200 Subject: [PATCH 2/2] cleaner solution --- src/Composer/Command/ShowCommand.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 7dc691b7b..b4f5de49b 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -196,13 +196,12 @@ EOT $width--; } - $writePath = !$input->getOption('name-only') && $input->getOption('path'); - - if ($writePath && null === $composer) { + if ($input->getOption('path') && null === $composer) { $this->getIO()->writeError('No composer.json found in the current directory, disabling "path" option'); - $writePath = false; + $input->setOption('path', false); } + $writePath = !$input->getOption('name-only') && $input->getOption('path'); $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) {