Skip to content

Commit e13e215

Browse files
authored
Merge pull request #1449 from hydephp/fancy-serve-command
Fancy serve command cleanup
2 parents d325a10 + afca62e commit e13e215

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
class ServeCommand extends Command
2323
{
2424
/** @var string */
25-
protected $signature = 'serve {--host= : <comment>[default: "localhost"]</comment>}} {--port= : <comment>[default: 8080]</comment>}';
25+
protected $signature = 'serve
26+
{--host= : <comment>[default: "localhost"]</comment>}}
27+
{--port= : <comment>[default: 8080]</comment>}
28+
';
2629

2730
/** @var string */
2831
protected $description = 'Start the realtime compiler server.';

packages/realtime-compiler/src/Http/DashboardController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ public function __construct()
5656
{
5757
$this->title = config('hyde.name').' - Dashboard';
5858
$this->request = Request::capture();
59-
$this->console = new ConsoleOutput();
59+
60+
if (((bool) env('HYDE_RC_REQUEST_OUTPUT', false)) === true) {
61+
$this->console = new ConsoleOutput();
62+
}
6063

6164
$this->loadFlashData();
6265

@@ -355,7 +358,7 @@ protected function createPage(): void
355358
$this->abort($exception->getCode(), $exception->getMessage());
356359
}
357360

358-
$this->console->printMessage("Created file '$path'", 'dashboard@createPage');
361+
$this->writeToConsole("Created file '$path'", 'dashboard@createPage');
359362

360363
$this->flash('justCreatedPage', RouteKey::fromPage($pageClass, $pageClass::pathToIdentifier($path))->get());
361364
$this->setJsonResponse(201, "Created file '$path'!");
@@ -510,4 +513,11 @@ protected function hasAsyncHeaders(): bool
510513
{
511514
return (getallheaders()['X-RC-Handler'] ?? getallheaders()['x-rc-handler'] ?? null) === 'Async';
512515
}
516+
517+
protected function writeToConsole(string $message, string $context = 'dashboard'): void
518+
{
519+
if (isset($this->console)) {
520+
$this->console->printMessage($message, $context);
521+
}
522+
}
513523
}

0 commit comments

Comments
 (0)