diff --git a/RoboFile.dist.ini b/RoboFile.dist.ini index 2980766..8d3a728 100644 --- a/RoboFile.dist.ini +++ b/RoboFile.dist.ini @@ -1 +1,2 @@ -skipClone = true \ No newline at end of file +skipClone = true +cmsPath = /path/to/my/local/website/root \ No newline at end of file diff --git a/RoboFile.php b/RoboFile.php index a104e85..216acce 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -19,6 +19,8 @@ class RoboFile extends \Robo\Tasks private $configuration = array(); + private $cmsPath = ''; + /** * Set the Execute extension for Windows Operating System * @@ -44,6 +46,8 @@ class RoboFile extends \Robo\Tasks { $this->configuration = $this->getConfiguration(); + $this->cmsPath = $this->getCmsPath(); + $this->setExecExtension(); $this->createTestingSite(); @@ -165,18 +169,18 @@ class RoboFile extends \Robo\Tasks public function createTestingSite() { if (!empty($this->configuration->skipClone)) { - $this->say('Reusing Joomla CMS site already present at tests/joomla-cms3'); + $this->say('Reusing Joomla CMS site already present at ' . $this->cmsPath); return; } // Get Joomla Clean Testing sites - if (is_dir('tests/joomla-cms3')) + if (is_dir($this->cmsPath)) { - $this->taskDeleteDir('tests/joomla-cms3')->run(); + $this->taskDeleteDir($this->cmsPath)->run(); } - $this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/joomla-cms3'); - $this->say('Joomla CMS site created at tests/joomla-cms3'); + $this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git ' . $this->cmsPath); + $this->say('Joomla CMS site created at ' . $this->cmsPath); } /** @@ -202,6 +206,25 @@ class RoboFile extends \Robo\Tasks return json_decode(json_encode($configuration)); } + /** + * Get the correct CMS root path + * + * @return string + */ + private function getCmsPath() + { + if (empty($this->configuration->cmsPath)) { + return 'tests/joomla-cms3'; + } + + if (!file_exists(dirname($this->configuration->cmsPath))) { + $this->say("Cms path written in local configuration does not exists or is not readable"); + return 'tests/joomla-cms3'; + } + + return $this->configuration->cmsPath; + } + /** * Runs Selenium Standalone Server. *