Skip to content

Commit ff38879

Browse files
Copilotdermatz
andcommitted
#feature-request - Address code review feedback for CleanCommand
Co-authored-by: dermatz <6103201+dermatz@users.noreply.github.com>
1 parent 759ec08 commit ff38879

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/Console/Command/Static/CleanCommand.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function cleanThemeDirectories(string $basePath, string $themeCode): int
246246
$cleaned = 0;
247247

248248
// Scan for areas (frontend, adminhtml, etc.)
249-
$areas = ['frontend'];
249+
$areas = ['frontend', 'adminhtml'];
250250
foreach ($areas as $area) {
251251
$areaPath = $basePath . DIRECTORY_SEPARATOR . $area;
252252
if (!is_dir($areaPath)) {
@@ -281,10 +281,22 @@ private function removeDirectory(string $dir): bool
281281
$files = array_diff(scandir($dir), ['.', '..']);
282282
foreach ($files as $file) {
283283
$path = $dir . DIRECTORY_SEPARATOR . $file;
284-
is_dir($path) ? $this->removeDirectory($path) : unlink($path);
284+
if (is_dir($path)) {
285+
if (!$this->removeDirectory($path)) {
286+
throw new \RuntimeException(sprintf('Failed to remove directory: %s', $path));
287+
}
288+
} else {
289+
if (!@unlink($path)) {
290+
throw new \RuntimeException(sprintf('Failed to remove file: %s', $path));
291+
}
292+
}
293+
}
294+
295+
if (!@rmdir($dir)) {
296+
throw new \RuntimeException(sprintf('Failed to remove directory: %s', $dir));
285297
}
286298

287-
return rmdir($dir);
299+
return true;
288300
} catch (\Exception $e) {
289301
$this->io->error('Failed to remove directory: ' . $e->getMessage());
290302
return false;

0 commit comments

Comments
 (0)