Skip to content

Commit

Permalink
Allow for .ts routes file
Browse files Browse the repository at this point in the history
  • Loading branch information
Stnaire committed Feb 24, 2024
1 parent 3600edd commit d51ddb2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/CommandRouteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ public function handle()
$this->makeDirectory($path);
}

$name = preg_replace('/(\.d)?\.ts$|\.js$/', '', $path);

if (! $this->option('types-only')) {
$output = config('ziggy.output.file', File::class);
$normalizedPath = preg_match('/\.(js|ts)$/', $path) ? $path : "$path.js";

$this->files->put(base_path("{$name}.js"), new $output($ziggy));
$this->files->put(base_path($normalizedPath), new $output($ziggy));
}

if ($this->option('types') || $this->option('types-only')) {
$types = config('ziggy.output.types', Types::class);
$normalizedPath = preg_replace('/(\.d)?\.ts$|\.js$/', '', $path);

$this->files->put(base_path("{$name}.d.ts"), new $types($ziggy));
$this->files->put(base_path("{$normalizedPath}.d.ts"), new $types($ziggy));
}

$this->info('Files generated!');
Expand Down

0 comments on commit d51ddb2

Please sign in to comment.