From 55a5bfd16896862c0715db54fac6d367ff86d622 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 25 Oct 2014 13:29:07 +0530 Subject: [PATCH] Skip plugins which do not have webroot. --- src/Shell/Task/AssetsTask.php | 25 +++++++++++++------- tests/TestCase/Shell/Task/AssetsTaskTest.php | 12 ++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/Shell/Task/AssetsTask.php b/src/Shell/Task/AssetsTask.php index d2a845d68de..55ca2842923 100644 --- a/src/Shell/Task/AssetsTask.php +++ b/src/Shell/Task/AssetsTask.php @@ -32,23 +32,31 @@ class AssetsTask extends Shell { * @return void */ public function main() { - $this->_symlink(); + $this->_process(); } /** - * Symlink folder + * Process plugins * * @return void */ - protected function _symlink() { - $this->out(); - $this->out(); - $this->out('Symlinking...'); - $this->hr(); + protected function _process() { $plugins = Plugin::loaded(); foreach ($plugins as $plugin) { - $this->out('For plugin: ' . $plugin); + $path = Plugin::path($plugin) . 'webroot'; + if (!is_dir($path)) { + $this->out(); + $this->out( + sprintf('Skipping plugin %s. It does not have webroot folder.', $plugin), + 2, + Shell::VERBOSE + ); + continue; + } + $this->out(); + $this->out('For plugin: ' . $plugin); + $this->hr(); $link = Inflector::underscore($plugin); $dir = WWW_ROOT; @@ -71,7 +79,6 @@ protected function _symlink() { } } - $path = Plugin::path($plugin) . 'webroot'; $this->out('Creating symlink: ' . $dir); $this->out(); // @codingStandardsIgnoreStart diff --git a/tests/TestCase/Shell/Task/AssetsTaskTest.php b/tests/TestCase/Shell/Task/AssetsTaskTest.php index 8cbb91ec911..7c187249e4b 100644 --- a/tests/TestCase/Shell/Task/AssetsTaskTest.php +++ b/tests/TestCase/Shell/Task/AssetsTaskTest.php @@ -79,4 +79,16 @@ public function testExecute() { $folder->delete(); } +/** + * testExecute method + * + * @return void + */ + public function testForPluginWithoutWebroot() { + Plugin::load('TestPluginTwo'); + + $this->Task->main(); + $this->assertFalse(file_exists(WWW_ROOT . 'test_plugin_two')); + } + }