Skip to content

Commit

Permalink
[TEMP] Supporting our vendor/ structure
Browse files Browse the repository at this point in the history
  • Loading branch information
karoun committed Jun 25, 2018
1 parent 20aa3b3 commit 8dc6fd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/ComposerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function activate(Composer $composer, IOInterface $io) {
$vendor = $composer->getConfig()->get('vendor-dir', '/');

$this->vendor = $vendor;
$this->root = dirname($vendor);
// TODO: Remove this hard-coded path in favor of config
$this->root = dirname(dirname($vendor));
}

public static function getSubscribedEvents() {
Expand All @@ -55,7 +56,8 @@ public function onPostAutoloadDump(Event $event) {
$this->root,
$event->isDevMode()
? IncludedRoots::DEV_AND_PROD
: IncludedRoots::PROD_ONLY
: IncludedRoots::PROD_ONLY,
$this->vendor
);

$handler = $event->isDevMode()
Expand Down
9 changes: 6 additions & 3 deletions src/builders/RootImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class RootImporter implements Builder {
public function __construct(
string $root,
IncludedRoots $included = IncludedRoots::PROD_ONLY,
?string $vendor = null,
) {
$this->hh_importer = new HHImporter($root, $included);
$this->builders[] = $this->hh_importer;
Expand All @@ -27,15 +28,17 @@ public function __construct(
return;
}

foreach (glob($root.'/vendor/*/*/') as $dependency) {
if (file_exists($dependency.'/hh_autoload.json')) {
$vendor = $vendor ?? $root.'/vendor';

foreach (glob($vendor.'/*/*/', GLOB_ONLYDIR | GLOB_MARK) as $dependency) {
if (file_exists($dependency.'hh_autoload.json')) {
$this->builders[] = new HHImporter(
$dependency,
IncludedRoots::PROD_ONLY,
);
continue;
}
$composer_json = $dependency.'/composer.json';
$composer_json = $dependency.'composer.json';
if (file_exists($composer_json)) {
$this->builders[] = new ComposerImporter($composer_json, $config);
continue;
Expand Down

0 comments on commit 8dc6fd4

Please sign in to comment.