Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

Commit e3ae5ad

Browse files
committed
Add functionality to run Pint on generated test files
1 parent 4b348db commit e3ae5ad

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Commands/FilamentTestsCommand.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Filesystem\Filesystem;
1111
use Illuminate\Support\Collection;
12+
use Illuminate\Support\Facades\Process;
1213

1314
use function Laravel\Prompts\multiselect;
1415

@@ -23,6 +24,7 @@ class FilamentTestsCommand extends Command
2324
public function __construct(
2425
protected ?Collection $resources = null,
2526
protected ?Collection $panels = null,
27+
protected array $generatedFiles = [],
2628
protected ?Filesystem $files = null,
2729
) {
2830
$this->resources ??= collect();
@@ -52,9 +54,13 @@ public function handle(): void
5254

5355
file_put_contents($filePath, $rendered);
5456

57+
$this->generatedFiles[] = $filePath;
58+
5559
$this->info("Created test for {$resourceClass}{$filePath}");
5660
}
5761
}
62+
63+
$this->runPintOnGeneratedFiles();
5864
}
5965

6066
protected function renderTestsForResource(string $resourceClass): string
@@ -129,4 +135,15 @@ public function askUserToSelectWhichResourcesFromTheSelectedPanel(): Collection
129135

130136
return $selectedResources;
131137
}
138+
139+
protected function runPintOnGeneratedFiles(): void
140+
{
141+
if ($this->generatedFiles === []) {
142+
return;
143+
}
144+
145+
$files = implode(' ', $this->generatedFiles);
146+
147+
Process::run("vendor/bin/pint {$files}");
148+
}
132149
}

src/Concerns/Resources/InteractsWithTableActions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public function getResourceTableActions(): array
1313

1414
public function getResourceTableVisibleActions(): array
1515
{
16-
return array_filter($this->getResourceTableActions(), fn(Action $action): bool => ! $this->getPrivateProperty($action, 'isHidden'));
16+
return array_filter($this->getResourceTableActions(), fn (Action $action): bool => ! $this->getPrivateProperty($action, 'isHidden'));
1717
}
1818
}

0 commit comments

Comments
 (0)