From c917f67bbb8bb4f4e1dbe06d0f66d608f863d2f7 Mon Sep 17 00:00:00 2001 From: Allan Maia Date: Fri, 10 Nov 2023 17:23:16 -0300 Subject: [PATCH] Add no_throw check to CLI running --- src/Component/ProcessRunner/ProcessRunner.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Component/ProcessRunner/ProcessRunner.php b/src/Component/ProcessRunner/ProcessRunner.php index cbd78cdb3..2f7dcc844 100644 --- a/src/Component/ProcessRunner/ProcessRunner.php +++ b/src/Component/ProcessRunner/ProcessRunner.php @@ -73,13 +73,15 @@ public function run(Host $host, string $command, array $config = []): string $process->mustRun($callback); return $process->getOutput(); } catch (ProcessFailedException $exception) { - throw new RunException( - $host, - $command, - $process->getExitCode(), - $process->getOutput(), - $process->getErrorOutput() - ); + if (!$config['no_throw']) { + throw new RunException( + $host, + $command, + $process->getExitCode(), + $process->getOutput(), + $process->getErrorOutput() + ); + } } catch (ProcessTimedOutException $exception) { // @phpstan-ignore-line can be thrown but is absent from the phpdoc throw new TimeoutException( $command,