From 332a0b9e040d3757f54b26e28a9345efcafd06d8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 7 Nov 2023 14:40:58 +0100 Subject: [PATCH] Remove ANSI colors from console output. --- app/Http/Livewire/Project/Shared/GetLogs.php | 2 +- bootstrap/helpers/shared.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Livewire/Project/Shared/GetLogs.php b/app/Http/Livewire/Project/Shared/GetLogs.php index b693793cf..4244bed12 100644 --- a/app/Http/Livewire/Project/Shared/GetLogs.php +++ b/app/Http/Livewire/Project/Shared/GetLogs.php @@ -17,7 +17,7 @@ class GetLogs extends Component public int $numberOfLines = 100; public function doSomethingWithThisChunkOfOutput($output) { - $this->outputs .= $output; + $this->outputs .= removeAnsiColors($output); } public function instantSave() { diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 8e8b2ec3e..013821bd7 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -501,3 +501,6 @@ function generateDeployWebhook($resource) { $url = $api . $endpoint . "?uuid=$uuid&force=false"; return $url; } +function removeAnsiColors($text) { + return preg_replace('/\e[[][A-Za-z0-9];?[0-9]*m?/', '', $text); +}