Skip to content

Commit 09994f3

Browse files
committed
fixing bug always show folder service or directori on call artisan
1 parent 2fdb800 commit 09994f3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/RepositoryServiceProvider.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,20 @@ public function getRepository()
120120
*/
121121
private function getRepositoryPath()
122122
{
123-
$this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.repository_directory"));
124-
$dirs = File::directories($this->app->basePath() .
125-
"/" . config("easy-repository.repository_directory"));
126123
$folders = [];
124+
if(file_exists($this->app->basePath() . "/" . config("easy-repository.repository_directory"))) {
125+
$dirs = File::directories($this->app->basePath() .
126+
"/" . config("easy-repository.repository_directory"));
127+
foreach ($dirs as $dir) {
128+
$arr = explode("/", $dir);
127129

128-
foreach ($dirs as $dir) {
129-
$arr = explode("/", $dir);
130+
$folders[] = end($arr);
131+
}
132+
} else {
130133

131-
$folders[] = end($arr);
132134
}
133135

136+
134137
return $folders;
135138
}
136139

@@ -189,16 +192,19 @@ private function getRepositoryFiles()
189192
* @return array
190193
*/
191194
private function getServicePath() {
192-
$this->app->make(Filesystem::class)->ensureDirectoryExists(config("easy-repository.service_directory"));
193195
$root = $this->app->basePath() .
194196
"/" . config("easy-repository.service_directory");
197+
$servicePath = [];
195198

196-
$path = Search::file($root, ["php"]);
199+
if(file_exists($root)) {
200+
$path = Search::file($root, ["php"]);
197201

198-
$servicePath = [];
199-
foreach ($path as $file) {
200-
$servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services"));
202+
203+
foreach ($path as $file) {
204+
$servicePath[] = str_replace("Services/","",strstr($file->getPath(), "Services"));
205+
}
201206
}
207+
202208
return array_unique($servicePath);
203209
}
204210

0 commit comments

Comments
 (0)