Skip to content

Commit 79b6ba3

Browse files
committed
fix: skip message twice
1 parent c83b8f9 commit 79b6ba3

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Commands/Setup.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)