Skip to content

Commit

Permalink
refactor(config): use platofmr runtime directory seperator const for …
Browse files Browse the repository at this point in the history
…directory sperator

Signed-off-by: Fred Myerscough <[email protected]>
  • Loading branch information
oniice committed May 16, 2024
1 parent 9729573 commit 9d5d21b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/Framework/Config/PackageDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

class PackageDiscovery
{
private Finder $finder;

readonly public array $found;

readonly protected array $providers;

readonly protected array $commands;
private Finder $finder;

public function __construct(string $root)
{
Expand All @@ -21,11 +18,6 @@ public function __construct(string $root)
$this->found = $this->finder->discover('acorn');
}

protected function locatePackage(string $package): string
{
return trim($this->finder->locate($package));
}

/**
* Discover all command directories registered by installed packages
*
Expand All @@ -39,7 +31,7 @@ public function locateCommands(): array
$commands = $meta['commands'] ?? false;
if ($commands === true) {
$packageLocation = $this->locatePackage($package);
$commandDirectory = $packageLocation . DIRECTORY_SEPARATOR . 'app/Commands';
$commandDirectory = $packageLocation . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Commands';
$commandLocations[$package] = $commandDirectory;
}
}
Expand All @@ -60,11 +52,16 @@ public function locateProviders(): array
$providers = $meta['providers'] ?? false;
if ($providers === true) {
$packageLocation = $this->locatePackage($package);
$providerDirectory = $packageLocation . DIRECTORY_SEPARATOR . 'app/Providers';
$providerDirectory = $packageLocation . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'Providers';
$providerClasses[$package] = $providerDirectory;
}
}

return $providerClasses;
}

protected function locatePackage(string $package): string
{
return trim($this->finder->locate($package));
}
}

0 comments on commit 9d5d21b

Please sign in to comment.