Skip to content

Commit

Permalink
Generator: Add support for find other packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Feb 20, 2020
1 parent d438905 commit b88fbdd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Generator.php
Expand Up @@ -81,7 +81,7 @@ public function run(): PackageDescriptorEntity

/**
* @param string[][] $composer
* @return string[][]|string[][][]|string[][][][]
* @return mixed[]
* @throws PackageDescriptorException
*/
private function getPackages(array $composer): array
Expand All @@ -94,7 +94,22 @@ private function getPackages(array $composer): array
$packagesVersions = [];
}

foreach (array_merge($composer['require'], $packagesVersions) as $name => $dependency) {
$packageDirs = array_merge($composer['require'], $packagesVersions);

// Find other packages
foreach (new \DirectoryIterator($this->projectRoot . '/vendor') as $vendorNamespace) {
if ($vendorNamespace->isDir() === true && ($namespace = $vendorNamespace->getFilename()) !== '.' && $namespace !== '..') {
foreach (new \DirectoryIterator($this->projectRoot . '/vendor/' . $namespace) as $packageName) {
if ($packageName->isDir() === true && ($name = $packageName->getFilename()) !== '.' && $name !== '..'
&& isset($packageDirs[$package = $namespace . '/' . $name]) === false
) {
$packageDirs[$package] = '*';
}
}
}
}

foreach ($packageDirs as $name => $dependency) {
if (is_dir($path = $this->projectRoot . '/vendor/' . ($name = mb_strtolower($name, 'UTF-8'))) === false) {
continue;
}
Expand Down Expand Up @@ -190,4 +205,4 @@ private function getPackagesVersions(): array
return $return;
}

}
}

0 comments on commit b88fbdd

Please sign in to comment.