Return the composer.json content instead of a zip:// path
parent
0d0cb53f31
commit
a91fd20673
|
@ -83,15 +83,13 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
|
||||||
|
|
||||||
private function getComposerInformation(\SplFileInfo $file)
|
private function getComposerInformation(\SplFileInfo $file)
|
||||||
{
|
{
|
||||||
$composerFile = Zip::findComposerJson($file->getPathname());
|
$json = Zip::getComposerJson($file->getPathname());
|
||||||
|
|
||||||
if (null === $composerFile) {
|
if (null === $json) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = file_get_contents($composerFile);
|
$package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
|
||||||
|
|
||||||
$package = JsonFile::parseJson($json, $composerFile);
|
|
||||||
$package['dist'] = array(
|
$package['dist'] = array(
|
||||||
'type' => 'zip',
|
'type' => 'zip',
|
||||||
'url' => strtr($file->getPathname(), '\\', '/'),
|
'url' => strtr($file->getPathname(), '\\', '/'),
|
||||||
|
|
|
@ -18,14 +18,14 @@ namespace Composer\Util;
|
||||||
class Zip
|
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 $pathToZip
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public static function findComposerJson($pathToZip)
|
public static function getComposerJson($pathToZip)
|
||||||
{
|
{
|
||||||
if (!extension_loaded('zip')) {
|
if (!extension_loaded('zip')) {
|
||||||
throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
|
throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
|
||||||
|
@ -49,10 +49,17 @@ class Zip
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$content = null;
|
||||||
$configurationFileName = $zip->getNameIndex($foundFileIndex);
|
$configurationFileName = $zip->getNameIndex($foundFileIndex);
|
||||||
|
$stream = $zip->getStream($configurationFileName);
|
||||||
|
|
||||||
|
if (false !== $stream) {
|
||||||
|
$content = stream_get_contents($stream);
|
||||||
|
}
|
||||||
|
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
return "zip://{$pathToZip}#$configurationFileName";
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue