1
0
Fork 0

Return the composer.json content instead of a zip:// path

pull/7994/head
Andreas Schempp 2019-03-04 09:54:35 +01:00
parent 0d0cb53f31
commit a91fd20673
2 changed files with 13 additions and 8 deletions

View File

@ -83,15 +83,13 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
private function getComposerInformation(\SplFileInfo $file)
{
$composerFile = Zip::findComposerJson($file->getPathname());
$json = Zip::getComposerJson($file->getPathname());
if (null === $composerFile) {
if (null === $json) {
return false;
}
$json = file_get_contents($composerFile);
$package = JsonFile::parseJson($json, $composerFile);
$package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
$package['dist'] = array(
'type' => 'zip',
'url' => strtr($file->getPathname(), '\\', '/'),

View File

@ -18,14 +18,14 @@ namespace Composer\Util;
class Zip
{
/**
* Finds the path to the root composer.json inside a ZIP archive.
* Gets content of the root composer.json inside a ZIP archive.
*
* @param string $pathToZip
* @param string $filename
*
* @return string|null
*/
public static function findComposerJson($pathToZip)
public static function getComposerJson($pathToZip)
{
if (!extension_loaded('zip')) {
throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
@ -49,10 +49,17 @@ class Zip
return null;
}
$content = null;
$configurationFileName = $zip->getNameIndex($foundFileIndex);
$stream = $zip->getStream($configurationFileName);
if (false !== $stream) {
$content = stream_get_contents($stream);
}
$zip->close();
return "zip://{$pathToZip}#$configurationFileName";
return $content;
}
/**