diff --git a/packages/framework/src/Console/Commands/ServeCommand.php b/packages/framework/src/Console/Commands/ServeCommand.php index 75240db7004..bc738dacb7b 100644 --- a/packages/framework/src/Console/Commands/ServeCommand.php +++ b/packages/framework/src/Console/Commands/ServeCommand.php @@ -22,7 +22,10 @@ class ServeCommand extends Command { /** @var string */ - protected $signature = 'serve {--host= : [default: "localhost"]}} {--port= : [default: 8080]}'; + protected $signature = 'serve + {--host= : [default: "localhost"]}} + {--port= : [default: 8080]} + '; /** @var string */ protected $description = 'Start the realtime compiler server.'; diff --git a/packages/realtime-compiler/src/Http/DashboardController.php b/packages/realtime-compiler/src/Http/DashboardController.php index 1e282a4f4f5..b129a16aedd 100644 --- a/packages/realtime-compiler/src/Http/DashboardController.php +++ b/packages/realtime-compiler/src/Http/DashboardController.php @@ -56,7 +56,10 @@ public function __construct() { $this->title = config('hyde.name').' - Dashboard'; $this->request = Request::capture(); - $this->console = new ConsoleOutput(); + + if (((bool) env('HYDE_RC_REQUEST_OUTPUT', false)) === true) { + $this->console = new ConsoleOutput(); + } $this->loadFlashData(); @@ -355,7 +358,7 @@ protected function createPage(): void $this->abort($exception->getCode(), $exception->getMessage()); } - $this->console->printMessage("Created file '$path'", 'dashboard@createPage'); + $this->writeToConsole("Created file '$path'", 'dashboard@createPage'); $this->flash('justCreatedPage', RouteKey::fromPage($pageClass, $pageClass::pathToIdentifier($path))->get()); $this->setJsonResponse(201, "Created file '$path'!"); @@ -510,4 +513,11 @@ protected function hasAsyncHeaders(): bool { return (getallheaders()['X-RC-Handler'] ?? getallheaders()['x-rc-handler'] ?? null) === 'Async'; } + + protected function writeToConsole(string $message, string $context = 'dashboard'): void + { + if (isset($this->console)) { + $this->console->printMessage($message, $context); + } + } }