1313use DragonCode \LaravelActions \Repositories \ActionRepository ;
1414use DragonCode \LaravelActions \Services \Migrator ;
1515use DragonCode \LaravelActions \Values \Options ;
16+ use DragonCode \Support \Facades \Helpers \Arr ;
1617use DragonCode \Support \Facades \Helpers \Str ;
1718use DragonCode \Support \Filesystem \File ;
1819use Illuminate \Console \OutputStyle ;
@@ -47,13 +48,11 @@ protected function getFiles(string $path, ?Closure $filter = null): array
4748 {
4849 $ file = Str::finish ($ path , '.php ' );
4950
50- if ($ this ->file ->exists ($ file ) && $ this ->file ->isFile ($ file )) {
51- return [$ file ];
52- }
51+ $ files = $ this ->isFile ($ file ) ? [$ file ] : $ this ->file ->names ($ path , $ filter , true );
5352
54- return $ this ->sorter ->byValues (
55- $ this -> file -> names ( $ path , $ filter , true )
56- );
53+ return Arr:: of ( $ this ->sorter ->byValues ($ files ))
54+ -> map ( fn ( string $ value ) => Str:: before ( $ value , ' .php ' ) )
55+ -> toArray ( );
5756 }
5857
5958 protected function runCommand (string $ command , array $ options = []): void
@@ -76,4 +75,9 @@ protected function fireEvent(string $event, string $method): void
7675 {
7776 $ this ->events ->dispatch (new $ event ($ method , $ this ->options ->before ));
7877 }
78+
79+ protected function isFile (string $ path ): bool
80+ {
81+ return $ this ->file ->exists ($ path ) && $ this ->file ->isFile ($ path );
82+ }
7983}
0 commit comments