From a63ce7cf96441a32ba70ef63b924c84422e91a98 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 27 Oct 2022 16:21:53 +0200 Subject: [PATCH] Add message when doing composer outdated --direct and there is nothing to show, fixes #11152 (#11156) --- src/Composer/Command/ShowCommand.php | 6 +++++- tests/Composer/Test/Command/ShowCommandTest.php | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/ShowCommand.php b/src/Composer/Command/ShowCommand.php index c7497d390..f90b8160b 100644 --- a/src/Composer/Command/ShowCommand.php +++ b/src/Composer/Command/ShowCommand.php @@ -615,7 +615,11 @@ EOT $io->writeError('Everything up to date'); } } else { - $this->printPackages($io, $packages, $indent, $versionFits, $latestFits, $descriptionFits, $width, $versionLength, $nameLength, $latestLength); + if ($writeLatest && \count($packages) === 0) { + $io->writeError('All your direct dependencies are up to date'); + } else { + $this->printPackages($io, $packages, $indent, $versionFits, $latestFits, $descriptionFits, $width, $versionLength, $nameLength, $latestLength); + } } if ($showAllTypes) { diff --git a/tests/Composer/Test/Command/ShowCommandTest.php b/tests/Composer/Test/Command/ShowCommandTest.php index e34bb193b..ea1284f7c 100644 --- a/tests/Composer/Test/Command/ShowCommandTest.php +++ b/tests/Composer/Test/Command/ShowCommandTest.php @@ -123,6 +123,14 @@ outdated/major 1.0.0 ~ 2.0.0', ], ]; + yield 'outdated deps with --direct show msg if all up to date' => [ + ['command' => 'outdated', '--direct' => true], + 'All your direct dependencies are up to date', + [ + 'vendor/package' => '*', + ], + ]; + yield 'outdated deps with --major-only only shows major updates' => [ ['command' => 'outdated', '--major-only' => true], 'Legend: