Skip to content

Commit

Permalink
Prevent errors when process output empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sangnguyenplus authored Feb 12, 2023
1 parent 401a3c4 commit 17d8075
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Commands/PreCommitHookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ public function handle(): int

$process->run();

$result = json_decode($process->getOutput(), true);

render(
view('git-commit-checker::summary', [
'result' => $result,
'isSuccessful' => $process->isSuccessful(),
])
);

if (! $process->isSuccessful()) {
return self::FAILURE;
if ($process->getOutput()) {
$result = json_decode($process->getOutput(), true);

render(
view('git-commit-checker::summary', [
'result' => $result,
'isSuccessful' => $process->isSuccessful(),
])
);

if (! $process->isSuccessful()) {
return self::FAILURE;
}
}

return self::SUCCESS;
Expand Down

0 comments on commit 17d8075

Please sign in to comment.