Skip to content

Commit

Permalink
fix locating source directory and determining project variant
Browse files Browse the repository at this point in the history
fixes #1
thanks to @undijke
  • Loading branch information
Mulkave committed Dec 10, 2020
1 parent 8c5ec43 commit 54cfb49
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,11 @@ private function mapFuzzyResults($results)

/**
* Get the source directory name.
* In a microservice installation this will be `app`. `src` otherwise.
*
* @return string
*/
public function getSourceDirectoryName()
{
if (file_exists(base_path(). DS .$this->srcDirectoryName)) {
return $this->srcDirectoryName;
}

return 'app';
}

Expand All @@ -118,15 +113,15 @@ public function getSourceDirectoryName()
*/
public function isMicroservice()
{
return !($this->getSourceDirectoryName() === $this->srcDirectoryName);
return !file_exists(base_path().DS.$this->getSourceDirectoryName().DS.'Services');
}

/**
* Get the namespace used for the application.
*
* @return string
*
* @throws \Exception
* @throws Exception
*/
public function findNamespace(string $dir)
{
Expand All @@ -135,6 +130,7 @@ public function findNamespace(string $dir)

// see which one refers to the "src/" directory
foreach ($composer['autoload']['psr-4'] as $namespace => $directory) {
$directory = str_replace(['/', '\\'], DS, $directory);
if ($directory === $dir.DS) {
return trim($namespace, '\\');
}
Expand Down

0 comments on commit 54cfb49

Please sign in to comment.