diff --git a/library/think/console/command/Clear.php b/library/think/console/command/Clear.php
index 9c3a0e90..41019cea 100644
--- a/library/think/console/command/Clear.php
+++ b/library/think/console/command/Clear.php
@@ -28,17 +28,27 @@ class Clear extends Command
protected function execute(Input $input, Output $output)
{
- $path = $input->getOption('path') ?: RUNTIME_PATH;
+ $path = $input->getOption('path') ?: RUNTIME_PATH;
+
+ if (is_dir($path)) {
+ $this->clearPath($path);
+ }
+
+ $output->writeln("Clear Successed");
+ }
+
+ protected function clearPath($path)
+ {
+ $path = realpath($path) . DS;
$files = scandir($path);
if ($files) {
foreach ($files as $file) {
if ('.' != $file && '..' != $file && is_dir($path . $file)) {
- array_map('unlink', glob($path . $file . '/*.*'));
+ $this->clearPath($path . $file);
} elseif ('.gitignore' != $file && is_file($path . $file)) {
unlink($path . $file);
}
}
}
- $output->writeln("Clear Successed");
}
}