@@ -196,10 +196,12 @@ protected function add(string $file, string $code, string $pattern, string $repl
196196 }
197197
198198 /**
199+ * Replace for setupHelper()
200+ *
199201 * @param string $file Relative file path like 'Controllers/BaseController.php'.
200202 * @param array $replaces [search => replace]
201203 */
202- protected function replace (string $ file , array $ replaces ): void
204+ private function replace (string $ file , array $ replaces ): bool
203205 {
204206 $ path = $ this ->distPath . $ file ;
205207 $ cleanPath = clean_path ($ path );
@@ -209,16 +211,18 @@ protected function replace(string $file, array $replaces): void
209211 $ output = $ this ->replacer ->replace ($ content , $ replaces );
210212
211213 if ($ output === $ content ) {
212- CLI ::error (" Skipped {$ cleanPath }. It has already been updated. " );
213-
214- return ;
214+ return false ;
215215 }
216216
217217 if (write_file ($ path , $ output )) {
218218 CLI ::write (CLI ::color (' Updated: ' , 'green ' ) . $ cleanPath );
219- } else {
220- CLI :: error ( " Error updating { $ cleanPath } . " ) ;
219+
220+ return true ;
221221 }
222+
223+ CLI ::error (" Error updating {$ cleanPath }. " );
224+
225+ return false ;
222226 }
223227
224228 private function setupHelper (): void
@@ -230,7 +234,10 @@ private function setupHelper(): void
230234 $ replaces = [
231235 '$this->helpers = array_merge($this->helpers, [ \'auth \', \'setting \']); ' => $ check ,
232236 ];
233- $ this ->replace ($ file , $ replaces );
237+ $ return = $ this ->replace ($ file , $ replaces );
238+ if ($ return ) {
239+ return ;
240+ }
234241
235242 // Add helper setup
236243 $ pattern = '/( ' . preg_quote ('// Do Not Edit This Line ' , '/ ' ) . ')/u ' ;
0 commit comments