Skip to content

Commit

Permalink
Fix: write bootstrap file only when missing routes API file (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodevs authored Jan 4, 2025
1 parent 3a67fdf commit 536879b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Generators/RouteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ protected function buildRouteLine($className, $slug, $method): string
protected function setupApiRouter(): void
{
$this->createApiRoutesFileIfMissing();
$this->configureApiRoutesInAppBootstrap();
}

protected function createApiRoutesFileIfMissing(): void
{
$apiPath = 'routes/api.php';
if (!$this->filesystem->exists($apiPath)) {
$this->filesystem->put($apiPath, $this->filesystem->stub('routes.api.stub'));
$this->configureApiRoutesInAppBootstrap();
}
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Feature/Generators/RouteGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ public function output_does_not_create_api_routes_file_when_it_exists(): void
->with('routes/api.php', $this->anything())
->never();

$this->filesystem->expects('replaceInFile')
->never();

$tokens = $this->blueprint->parse($this->fixture('drafts/api-routes-example.yaml'));
$tree = $this->blueprint->analyze($tokens);

Expand Down

0 comments on commit 536879b

Please sign in to comment.