From ed0829fed1772968d323319d575d3ea3a59e6137 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 28 Dec 2016 19:00:22 +0100 Subject: [PATCH] Simplify code and fix path to composer.json, refs #6001 --- src/Composer/Command/ShowCommand.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index 22ba028c2..0b9dc7616 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -168,17 +168,12 @@ EOT if (empty($package)) { $options = $input->getOptions(); - if (isset($options['working-dir'])) { - $composer_json = $options['working-dir'] . '/composer.json'; - if (file_exists($composer_json)) { - $io->writeError('Package ' . $packageFilter . ' not found in ' . $composer_json); - return; - } else { - throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found'); - } - } else { + if (!isset($options['working-dir']) || !file_exists('composer.json')) { throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found'); } + + $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json'); + return; } } else { $versions = array($package->getPrettyVersion() => $package->getVersion());