Adjust Zip Util to only find the root composer.json
parent
05d6b21785
commit
0d0cb53f31
|
@ -83,7 +83,7 @@ class ArtifactRepository extends ArrayRepository implements ConfigurableReposito
|
|||
|
||||
private function getComposerInformation(\SplFileInfo $file)
|
||||
{
|
||||
$composerFile = Zip::findFile($file->getPathname(), 'composer.json');
|
||||
$composerFile = Zip::findComposerJson($file->getPathname());
|
||||
|
||||
if (null === $composerFile) {
|
||||
return false;
|
||||
|
|
|
@ -18,15 +18,19 @@ namespace Composer\Util;
|
|||
class Zip
|
||||
{
|
||||
/**
|
||||
* Finds the path to a file inside a ZIP archive.
|
||||
* Finds the path to the root composer.json inside a ZIP archive.
|
||||
*
|
||||
* @param string $pathToZip
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function findFile($pathToZip, $filename)
|
||||
public static function findComposerJson($pathToZip)
|
||||
{
|
||||
if (!extension_loaded('zip')) {
|
||||
throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
|
||||
}
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
if ($zip->open($pathToZip) !== true) {
|
||||
return null;
|
||||
|
@ -38,7 +42,7 @@ class Zip
|
|||
return null;
|
||||
}
|
||||
|
||||
$foundFileIndex = self::locateFile($zip, $filename);
|
||||
$foundFileIndex = self::locateFile($zip, 'composer.json');
|
||||
if (false === $foundFileIndex) {
|
||||
$zip->close();
|
||||
|
||||
|
@ -68,7 +72,7 @@ class Zip
|
|||
$stat = $zip->statIndex($i);
|
||||
if (strcmp(basename($stat['name']), $filename) === 0) {
|
||||
$directoryName = dirname($stat['name']);
|
||||
if ($directoryName == '.') {
|
||||
if ($directoryName === '.') {
|
||||
//if composer.json is in root directory
|
||||
//it has to be the one to use.
|
||||
return $i;
|
||||
|
|
Loading…
Reference in New Issue