Ver código fonte

Clear all the caches

David Neilsen 10 anos atrás
pai
commit
be5eae5852
1 arquivos alterados com 21 adições e 12 exclusões
  1. 21 12
      src/Composer/Command/ClearCacheCommand.php

+ 21 - 12
src/Composer/Command/ClearCacheCommand.php

@@ -40,21 +40,30 @@ EOT
     {
         $config = Factory::createConfig();
         $io = $this->getIO();
-        
-        $cachePath = realpath($config->get('cache-repo-dir'));
-        if (!$cachePath) {
-            $io->write('<info>Cache directory does not exist.</info>');
-            return;
-        }
 
-        $cache = new Cache($io, $cachePath);
-        if (!$cache->isEnabled()) {
-            $io->write('<info>Cache is not enabled.</info>');
-            return;
+        $cachePaths = array(
+            $config->get('cache-dir'),
+            $config->get('cache-files-dir'),
+            $config->get('cache-repo-dir'),
+            $config->get('cache-vcs-dir'),
+        );
+
+        foreach ($cachePaths as $cachePath) {
+            $cachePath = realpath($cachePath);
+            if (!$cachePath) {
+                $io->write('<info>Cache directory does not exist.</info>');
+                return;
+            }
+            $cache = new Cache($io, $cachePath);
+            if (!$cache->isEnabled()) {
+                $io->write('<info>Cache is not enabled.</info>');
+                return;
+            }
+
+            $io->write('<info>Clearing cache in: '.$cachePath.'</info>');
+            $cache->gc(0, 0);
         }
 
-        $io->write('<info>Clearing cache in: '.$cachePath.'</info>');
-        $cache->gc(0, 0);
         $io->write('<info>Cache cleared.</info>');
     }
 }