Skip to content

Commit

Permalink
Refactor to extract helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 11, 2023
1 parent dc6c528 commit 8e90f48
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/framework/src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Closure;
use Hyde\Hyde;
use Hyde\Facades\Config;
use Illuminate\Support\Arr;
use Hyde\RealtimeCompiler\ConsoleOutput;
use Illuminate\Support\Facades\Process;
use LaravelZero\Framework\Commands\Command;
Expand Down Expand Up @@ -74,15 +75,10 @@ protected function getEnvironmentVariables(): array
'HYDE_RC_REQUEST_OUTPUT' => ! $this->option('no-ansi'),
];

if ($this->option('dashboard') !== null) {
$vars['HYDE_RC_SERVER_DASHBOARD'] = $this->option('dashboard') !== 'false' ? 'enabled' : 'disabled';
}

if ($this->option('pretty-urls') !== null) {
$vars['HYDE_PRETTY_URLS'] = $this->option('pretty-urls') !== 'false' ? 'enabled' : 'disabled';
}
$vars['HYDE_RC_SERVER_DASHBOARD'] = $this->parseEnvironmentOption('dashboard');
$vars['HYDE_PRETTY_URLS'] = $this->parseEnvironmentOption('pretty-urls');

return $vars;
return Arr::whereNotNull($vars);
}

protected function configureOutput(): void
Expand Down Expand Up @@ -110,4 +106,13 @@ protected function useBasicOutput(): bool
{
return $this->option('no-ansi') || ! class_exists(ConsoleOutput::class);
}

protected function parseEnvironmentOption(string $name): ?string
{
if ($this->option($name) !== null) {
return $this->option($name) !== 'false' ? 'enabled' : 'disabled';
} else {
return null;
}
}
}

0 comments on commit 8e90f48

Please sign in to comment.