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

Commit 1ebc1d6

Browse files
Merge pull request #304 from CodeWithDennis/add-pint-runner-option
Add option to run Pint on generated files after creating tests
2 parents b7a6dc3 + c136ba7 commit 1ebc1d6

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/Commands/FilamentTestsCommand.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
use Illuminate\Console\Command;
1212
use Illuminate\Filesystem\Filesystem;
1313
use Illuminate\Support\Collection;
14+
use Illuminate\Support\Facades\Process;
1415

1516
use function Laravel\Prompts\multiselect;
1617

1718
class FilamentTestsCommand extends Command
1819
{
19-
protected $signature = 'make:filament-test';
20+
protected $signature = 'make:filament-test
21+
{--skip-pint : Skip running Pint on generated files}';
2022

2123
protected $description = 'Create a new test for a Filament component';
2224

@@ -25,6 +27,7 @@ class FilamentTestsCommand extends Command
2527
public function __construct(
2628
protected ?Collection $resources = null,
2729
protected ?Collection $panels = null,
30+
protected array $generatedFiles = [],
2831
protected ?Filesystem $files = null,
2932
) {
3033
$this->resources ??= collect();
@@ -54,9 +57,13 @@ public function handle(): void
5457

5558
file_put_contents($filePath, $rendered);
5659

60+
$this->generatedFiles[] = $filePath;
61+
5762
$this->info("Created test for {$resourceClass}{$filePath}");
5863
}
5964
}
65+
66+
$this->runPintOnGeneratedFiles();
6067
}
6168

6269
/**
@@ -72,6 +79,21 @@ protected function renderTestsForResource(string $resourceClass): string
7279
]);
7380
}
7481

82+
protected function runPintOnGeneratedFiles(): void
83+
{
84+
if ($this->generatedFiles === []) {
85+
return;
86+
}
87+
88+
if ($this->option('skip-pint')) {
89+
return;
90+
}
91+
92+
$files = implode(' ', $this->generatedFiles);
93+
94+
Process::run("vendor/bin/pint {$files}");
95+
}
96+
7597
protected function getTestFilePath(string $resourceClass): string
7698
{
7799
$relativeClass = str($resourceClass)

0 commit comments

Comments
 (0)