Skip to content

Commit 5e40f9b

Browse files
committed
Refactor to use testable Illuminate process
1 parent 3fc283d commit 5e40f9b

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
use Hyde\Console\Concerns\Command;
1313
use Hyde\RealtimeCompiler\ConsoleOutput;
1414
use Illuminate\Support\Facades\Process;
15-
use Symfony\Component\Process\Process as SymfonyProcess;
16-
use Symfony\Component\Process\Exception\ProcessFailedException;
1715

1816
use function sprintf;
17+
use function str_replace;
1918
use function class_exists;
2019

2120
/**
@@ -152,13 +151,13 @@ protected function openInBrowser(): void
152151
default => null
153152
};
154153

155-
try {
156-
SymfonyProcess::fromShellCommandline(sprintf('%s http://%s:%d', $command, $this->getHostSelection(), $this->getPortSelection()))->mustRun();
157-
} catch (ProcessFailedException $exception) {
158-
$this->warn("Unable to open the site preview in the browser on your system.\n");
159-
if ($this->output->isVerbose()) {
160-
$this->line($exception->getMessage());
161-
}
154+
$process = Process::command(sprintf('%s http://%s:%d', $command, $this->getHostSelection(), $this->getPortSelection()))->run();
155+
156+
if ($process->failed()) {
157+
$this->warn('Unable to open the site preview in the browser on your system:');
158+
$this->line(sprintf(' %s', str_replace("\n", "\n ", $process->errorOutput())));
162159
}
160+
161+
$this->newLine();
163162
}
164163
}

0 commit comments

Comments
 (0)