diff --git a/src/Playwright/Servers/PlaywrightNpmServer.php b/src/Playwright/Servers/PlaywrightNpmServer.php index 31c9febe..518b99b9 100644 --- a/src/Playwright/Servers/PlaywrightNpmServer.php +++ b/src/Playwright/Servers/PlaywrightNpmServer.php @@ -60,11 +60,11 @@ public function start(): void return; } - $this->systemProcess = SystemProcess::fromShellCommandline(sprintf( + $this->systemProcess = new SystemProcess(explode(' ', sprintf( $this->command, $this->host, $this->port, - ), $this->baseDirectory, [ + )), $this->baseDirectory, [ 'APP_URL' => sprintf('http://%s:%d', $this->host, $this->port), ]); diff --git a/src/ServerManager.php b/src/ServerManager.php index dc5c7d55..44be9816 100644 --- a/src/ServerManager.php +++ b/src/ServerManager.php @@ -58,20 +58,22 @@ public function playwright(): PlaywrightServer return AlreadyStartedPlaywrightServer::fromPersisted(); } - $port = Port::find(); + if (! $this->playwright instanceof PlaywrightServer) { + $port = Port::find(); - $this->playwright ??= PlaywrightNpmServer::create( - PackageJsonDirectory::find(), - '.'.DIRECTORY_SEPARATOR.'node_modules'.DIRECTORY_SEPARATOR.'.bin'.DIRECTORY_SEPARATOR.'playwright run-server --host %s --port %d --mode launchServer', - self::DEFAULT_HOST, - $port, - 'Listening on', - ); + $this->playwright = PlaywrightNpmServer::create( + PackageJsonDirectory::find(), + '.'.DIRECTORY_SEPARATOR.'node_modules'.DIRECTORY_SEPARATOR.'.bin'.DIRECTORY_SEPARATOR.'playwright run-server --host %s --port %d --mode launchServer', + self::DEFAULT_HOST, + $port, + 'Listening on', + ); - AlreadyStartedPlaywrightServer::persist( - self::DEFAULT_HOST, - $port, - ); + AlreadyStartedPlaywrightServer::persist( + self::DEFAULT_HOST, + $port, + ); + } return $this->playwright; }