From e5cc8308dcb454a80beb31430a087f1973b79299 Mon Sep 17 00:00:00 2001 From: tale Date: Wed, 15 Mar 2017 10:56:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dclear=E6=8C=87=E4=BB=A4?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=88=A0=E9=99=A4=E5=A4=9A=E7=BA=A7=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E4=B8=8B=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/console/command/Clear.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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"); } }