From 13cc51fa0e128559b004151712cab0be912303c7 Mon Sep 17 00:00:00 2001 From: Osahenrumwen Aigbogun Date: Wed, 30 Oct 2024 11:02:08 +0100 Subject: [PATCH] Added exception for invalid json file --- src/BobDBuilder/Cmd/Traits/Make/Domain.php | 56 ++++++++++++---------- src/Libs/Symlink/LaySymlink.php | 3 ++ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/BobDBuilder/Cmd/Traits/Make/Domain.php b/src/BobDBuilder/Cmd/Traits/Make/Domain.php index e47a56e..b3b59ab 100644 --- a/src/BobDBuilder/Cmd/Traits/Make/Domain.php +++ b/src/BobDBuilder/Cmd/Traits/Make/Domain.php @@ -190,35 +190,41 @@ public function update_general_domain_entry(string $domain, string $domain_id, s ); DEF; - // Current Domain being created - preg_match( - '/Domain::new\(\)->create\([^)]*'. $domain_id .'[^)]*\);/s', - $index_page, $data - ); + $current_domain = ""; - // Create the new domain patterns as specified from the terminal - $pattern = ""; - foreach (explode(",", $patterns) as $p) { - $pattern .= '"' . strtolower(trim($p)) . '",'; - } + if($domain_id != 'default') { + // Current Domain being created + preg_match( + '/Domain::new\(\)->create\([^)]*' . $domain_id . '[^)]*\);/s', + $index_page, $data + ); - $pattern = rtrim($pattern, ","); - $old_pattern = null; + // Create the new domain patterns as specified from the terminal + $pattern = ""; + foreach (explode(",", $patterns) as $p) { + $pattern .= '"' . strtolower(trim($p)) . '",'; + } - if(!empty($data)) { - preg_match('/"([^"]+)"/', $data[0], $old_pattern); - $old_pattern = $old_pattern[0] ?? null; - } + $pattern = rtrim($pattern, ","); + $old_pattern = null; - $pattern = $old_pattern == $pattern ? $old_pattern : $pattern; + if (!empty($data)) { + preg_match('/"([^"]+)"/', $data[0], $old_pattern); + $old_pattern = $old_pattern[0] ?? null; + } - $current_domain = <<create( - id: "$domain_id", - builder: \Web\\$domain\\Plaster::class, - patterns: [$pattern], - ); - CUR; + $pattern = $old_pattern == $pattern ? $old_pattern : $pattern; + + $current_domain = <<create( + id: "$domain_id", + builder: \Web\\$domain\\Plaster::class, + patterns: [$pattern], + ); + + CUR; + } // Remove any duplicate from the domain entry $index_page = trim(preg_replace( @@ -233,9 +239,7 @@ public function update_general_domain_entry(string $domain, string $domain_id, s $main_file, <<