Browse Source

Skip plugins which do not have webroot.

ADmad 11 years ago
parent
commit
55a5bfd168
2 changed files with 28 additions and 9 deletions
  1. 16 9
      src/Shell/Task/AssetsTask.php
  2. 12 0
      tests/TestCase/Shell/Task/AssetsTaskTest.php

+ 16 - 9
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 @@ class AssetsTask extends Shell {
 				}
 			}
 
-			$path = Plugin::path($plugin) . 'webroot';
 			$this->out('Creating symlink: ' . $dir);
 			$this->out();
 			// @codingStandardsIgnoreStart

+ 12 - 0
tests/TestCase/Shell/Task/AssetsTaskTest.php

@@ -79,4 +79,16 @@ class SymlinkAssetsTaskTest extends TestCase {
 		$folder->delete();
 	}
 
+/**
+ * testExecute method
+ *
+ * @return void
+ */
+	public function testForPluginWithoutWebroot() {
+		Plugin::load('TestPluginTwo');
+
+		$this->Task->main();
+		$this->assertFalse(file_exists(WWW_ROOT . 'test_plugin_two'));
+	}
+
 }