1
0
Fork 0

Fix 'composer show --platform <package>' erroring if no composer.json is present (#11533)

Sort of related to #11046 (although this is not a regression, but didn't work before, either)
pull/11517/head^2
David Zülke 2023-07-21 11:28:36 +02:00 committed by GitHub
parent 9eb9e0dcb3
commit 07f706e57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -815,7 +815,7 @@ EOT
$io->write('<info>homepage</info> : ' . $package->getHomepage());
$io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
$io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
if ($installedRepo->hasPackage($package)) {
if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
if (is_string($path)) {
$io->write('<info>path</info> : ' . realpath($path));
@ -976,7 +976,7 @@ EOT
];
}
if ($installedRepo->hasPackage($package)) {
if (!PlatformRepository::isPlatformPackage($package->getName()) && $installedRepo->hasPackage($package)) {
$path = $this->requireComposer()->getInstallationManager()->getInstallPath($package);
if (is_string($path)) {
$path = realpath($path);

View File

@ -288,12 +288,19 @@ vendor/package 1.1.0 <highlight>! 1.2.0</highlight>", trim($appTester->getDispla
unlink('./composer.json');
unlink('./auth.json');
// listing packages
$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'show', '-p' => true]);
$output = trim($appTester->getDisplay(true));
foreach (Regex::matchAll('{^(\w+)}m', $output)->matches as $m) {
self::assertTrue(PlatformRepository::isPlatformPackage((string) $m[1]));
}
// getting a single package
$appTester->run(['command' => 'show', '-p' => true, 'package' => 'php']);
$appTester->assertCommandIsSuccessful();
$appTester->run(['command' => 'show', '-p' => true, '-f' => 'json', 'package' => 'php']);
$appTester->assertCommandIsSuccessful();
}
public function testOutdatedWithZeroMajor(): void