Skip to content

Commit bae2f7d

Browse files
Merge pull request #79 from TheDragonCode/3.x
Fixed file names
2 parents 260431f + dc4b617 commit bae2f7d

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/Processors/Processor.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use DragonCode\LaravelActions\Repositories\ActionRepository;
1414
use DragonCode\LaravelActions\Services\Migrator;
1515
use DragonCode\LaravelActions\Values\Options;
16+
use DragonCode\Support\Facades\Helpers\Arr;
1617
use DragonCode\Support\Facades\Helpers\Str;
1718
use DragonCode\Support\Filesystem\File;
1819
use 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
}

src/Services/Migrator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ protected function allowLogging(Action $action): bool
160160

161161
protected function resolvePath(string $filename, string $path): string
162162
{
163-
if ($this->file->exists($filename) && $this->file->isFile($filename)) {
164-
return $filename;
163+
$withExtension = Str::finish($filename, '.php');
164+
165+
if ($this->file->exists($withExtension) && $this->file->isFile($withExtension)) {
166+
return $withExtension;
165167
}
166168

167169
return Str::finish($path . DIRECTORY_SEPARATOR . $filename, '.php');

0 commit comments

Comments
 (0)