Skip to content

Commit 17d8075

Browse files
Prevent errors when process output empty
1 parent 401a3c4 commit 17d8075

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Diff for: src/Commands/PreCommitHookCommand.php

+13-11
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ public function handle(): int
4343

4444
$process->run();
4545

46-
$result = json_decode($process->getOutput(), true);
47-
48-
render(
49-
view('git-commit-checker::summary', [
50-
'result' => $result,
51-
'isSuccessful' => $process->isSuccessful(),
52-
])
53-
);
54-
55-
if (! $process->isSuccessful()) {
56-
return self::FAILURE;
46+
if ($process->getOutput()) {
47+
$result = json_decode($process->getOutput(), true);
48+
49+
render(
50+
view('git-commit-checker::summary', [
51+
'result' => $result,
52+
'isSuccessful' => $process->isSuccessful(),
53+
])
54+
);
55+
56+
if (! $process->isSuccessful()) {
57+
return self::FAILURE;
58+
}
5759
}
5860

5961
return self::SUCCESS;

0 commit comments

Comments
 (0)