info(ConsoleColor::yellow('[EXEC] ') . ConsoleColor::green($cmd)); $original_command = $cmd; $this->logCommandInfo($original_command); $this->last_cmd = $cmd = $this->getExecString($cmd); // echo $cmd . PHP_EOL; $this->passthru($cmd, $this->console_putput, $original_command, cwd: $this->cd); return $this; } public function execWithWrapper(string $wrapper, string $args): WindowsCmd { return $this->exec($wrapper . ' "' . str_replace('"', '^"', $args) . '"'); } public function execWithResult(string $cmd, bool $with_log = true): array { if ($with_log) { /* @phpstan-ignore-next-line */ logger()->info(ConsoleColor::blue('[EXEC] ') . ConsoleColor::green($cmd)); } else { logger()->debug('Running command with result: ' . $cmd); } $cmd = $this->getExecString($cmd); $result = $this->passthru($cmd, $this->console_putput, $cmd, capture_output: true, throw_on_error: false, cwd: $this->cd); $out = explode("\n", $result['output']); return [$result['code'], $out]; } public function setEnv(array $env): static { // windows currently does not support setting environment variables throw new SPCInternalException('Windows does not support setting environment variables in shell commands.'); } public function appendEnv(array $env): static { // windows currently does not support appending environment variables throw new SPCInternalException('Windows does not support appending environment variables in shell commands.'); } public function getLastCommand(): string { return $this->last_cmd; } private function getExecString(string $cmd): string { return $cmd; } }