From afdae9c0e2094e8e6f0884167caa1022df7d99bf Mon Sep 17 00:00:00 2001 From: Ed Reel Date: Tue, 27 Dec 2016 21:22:48 -0600 Subject: [PATCH] Do not throw InvalidArgumentException with the 'show' command if the working-dir argument is set and composer.json exists - This prevents scripts from aborting when looping through a directory of projects --- src/Composer/Command/ShowCommand.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index a6826d641..22ba028c2 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -166,8 +166,19 @@ EOT if (empty($package)) { list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version')); - if (!$package) { - throw new \InvalidArgumentException('Package '.$input->getArgument('package').' not found'); + 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 { + throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found'); + } } } else { $versions = array($package->getPrettyVersion() => $package->getVersion());