Skip to content

Commit

Permalink
Check for non-platform requirements before warning that no deps are i…
Browse files Browse the repository at this point in the history
…nstalled on show command, fixes #11760
  • Loading branch information
Seldaek committed Dec 22, 2023
1 parent 4a209b7 commit 12ed217
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Composer/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
}, $packages))]);
}

if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
$io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
if (!$installedRepo->getPackages()) {
$hasNonPlatformReqs = static function (array $reqs): bool {
return (bool) array_filter(array_keys($reqs), function (string $name) {
return !PlatformRepository::isPlatformPackage($name);
});
};

if ($hasNonPlatformReqs($rootPkg->getRequires()) || $hasNonPlatformReqs($rootPkg->getDevRequires())) {
$io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
}
}
}

Expand Down

0 comments on commit 12ed217

Please sign in to comment.