Skip to content

Commit 54cfb49

Browse files
committed
fix locating source directory and determining project variant
fixes #1 thanks to @undijke
1 parent 8c5ec43 commit 54cfb49

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/Finder.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,11 @@ private function mapFuzzyResults($results)
9898

9999
/**
100100
* Get the source directory name.
101-
* In a microservice installation this will be `app`. `src` otherwise.
102101
*
103102
* @return string
104103
*/
105104
public function getSourceDirectoryName()
106105
{
107-
if (file_exists(base_path(). DS .$this->srcDirectoryName)) {
108-
return $this->srcDirectoryName;
109-
}
110-
111106
return 'app';
112107
}
113108

@@ -118,15 +113,15 @@ public function getSourceDirectoryName()
118113
*/
119114
public function isMicroservice()
120115
{
121-
return !($this->getSourceDirectoryName() === $this->srcDirectoryName);
116+
return !file_exists(base_path().DS.$this->getSourceDirectoryName().DS.'Services');
122117
}
123118

124119
/**
125120
* Get the namespace used for the application.
126121
*
127122
* @return string
128123
*
129-
* @throws \Exception
124+
* @throws Exception
130125
*/
131126
public function findNamespace(string $dir)
132127
{
@@ -135,6 +130,7 @@ public function findNamespace(string $dir)
135130

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

0 commit comments

Comments
 (0)