Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to open site in the browser when starting the realtime compiler #1483

Merged
merged 8 commits into from
Dec 1, 2023
Prev Previous commit
Next Next commit
Move up newline
  • Loading branch information
caendesilva committed Nov 28, 2023
commit 8991a3db5c25f827649a5576855a5f592e26bef3
3 changes: 1 addition & 2 deletions packages/framework/src/Console/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
$this->printStartMessage();

if ($this->option('open')) {
$this->openInBrowser();

Check warning on line 49 in packages/framework/src/Console/Commands/ServeCommand.php

View check run for this annotation

Codecov / codecov/patch

packages/framework/src/Console/Commands/ServeCommand.php#L49

Added line #L49 was not covered by tests
}

$this->runServerProcess(sprintf('php -S %s:%d %s',
Expand Down Expand Up @@ -142,22 +142,21 @@
return null;
}

protected function openInBrowser(): void

Check warning on line 145 in packages/framework/src/Console/Commands/ServeCommand.php

View check run for this annotation

Codecov / codecov/patch

packages/framework/src/Console/Commands/ServeCommand.php#L145

Added line #L145 was not covered by tests
{
$command = match (PHP_OS_FAMILY) {
'Windows' => 'start',
'Darwin' => 'open',
'Linux' => 'xdg-open',
default => null
};

Check warning on line 152 in packages/framework/src/Console/Commands/ServeCommand.php

View check run for this annotation

Codecov / codecov/patch

packages/framework/src/Console/Commands/ServeCommand.php#L147-L152

Added lines #L147 - L152 were not covered by tests

$process = $command ? Process::command(sprintf('%s http://%s:%d', $command, $this->getHostSelection(), $this->getPortSelection()))->run() : null;

Check warning on line 154 in packages/framework/src/Console/Commands/ServeCommand.php

View check run for this annotation

Codecov / codecov/patch

packages/framework/src/Console/Commands/ServeCommand.php#L154

Added line #L154 was not covered by tests

if (! $process || $process->failed()) {
$this->warn('Unable to open the site preview in the browser on your system:');
$this->line(sprintf(' %s', str_replace("\n", "\n ", $process ? $process->errorOutput() : "Missing suitable 'open' binary.")));
$this->newLine();

Check warning on line 159 in packages/framework/src/Console/Commands/ServeCommand.php

View check run for this annotation

Codecov / codecov/patch

packages/framework/src/Console/Commands/ServeCommand.php#L156-L159

Added lines #L156 - L159 were not covered by tests
}

$this->newLine();
}
}
Loading