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

[9.x] This PR improves windows support and adds WSL support for the artisan docs command #43585

Merged
merged 1 commit into from Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 15 additions & 12 deletions src/Illuminate/Foundation/Console/DocsCommand.php
Expand Up @@ -388,25 +388,28 @@ protected function openViaCustomStrategy($url)
*/
protected function openViaBuiltInStrategy($url)
{
$binary = (new ExecutableFinder())->find(match ($this->systemOsFamily) {
'Darwin' => 'open',
'Windows' => 'start',
'Linux' => 'xdg-open',
});
if ($this->systemOsFamily === 'Windows') {
$process = tap(Process::fromShellCommandline(escapeshellcmd("start {$url}")))->run();

if (! $process->isSuccessful()) {
throw new ProcessFailedException($process);
}

return;
}

$binary = Collection::make(match ($this->systemOsFamily) {
'Darwin' => ['open'],
'Linux' => ['xdg-open', 'wslview'],
})->first(fn ($binary) => (new ExecutableFinder)->find($binary) !== null);

if ($binary === null) {
$this->components->warn('Unable to open the URL on your system. You will need to open it yourself or create a custom opener for your system.');

return;
}

$binaryExecutable = [
'Darwin' => 'open',
'Windows' => 'start',
'Linux' => 'xdg-open',
][$this->systemOsFamily];

$process = tap(Process::fromShellCommandline($binaryExecutable.' '.escapeshellcmd($url)))->run();
$process = tap(Process::fromShellCommandline(escapeshellcmd("{$binary} {$url}")))->run();

if (! $process->isSuccessful()) {
throw new ProcessFailedException($process);
Expand Down