diff --git a/DrushTask.php b/DrushTask.php index d0e28e5..4c73e2b 100644 --- a/DrushTask.php +++ b/DrushTask.php @@ -62,6 +62,7 @@ class DrushTask extends Task { private $bin = NULL; private $uri = NULL; private $root = NULL; + private $site_alias = NULL; private $assume = NULL; private $simulate = FALSE; private $pipe = FALSE; @@ -93,6 +94,10 @@ public function setRoot($str) { $this->root = $str; } + public function setSiteAlias($str) { + $this->site_alias = $str; + } + /** * URI of the Drupal to use. */ @@ -198,6 +203,7 @@ public function init() { $this->root = $this->getProject()->getProperty('drush.root'); $this->uri = $this->getProject()->getProperty('drush.uri'); $this->bin = $this->getProject()->getProperty('drush.bin'); + $this->site_alias = $this->getProject()->getProperty('drush.site_alias'); } /** @@ -212,7 +218,13 @@ public function main() { $option->setName('nocolor'); $this->options[] = $option; - if (!empty($this->root)) { + if (!empty($this->site_alias)) { + $param = new DrushParam(); + $param->addText($this->site_alias); + $command[] = $param->getValue(); + } + + if (!empty($this->root) && empty($this->site_alias)) { $option = new DrushOption(); $option->setName('root'); $option->addText($this->root); @@ -265,10 +277,13 @@ public function main() { // Execute Drush. $this->log("Executing '$command'..."); $output = array(); - exec($command, $output, $return); + exec($command . ' 2>&1', $output, $return); // Collect Drush output for display through Phing's log. foreach ($output as $line) { $this->log($line); + if ($this->haltonerror && strpos($line, 'Drush command terminated abnormally due to an unrecoverable error.') !== FALSE) { + throw new BuildException("Drush command terminated abnormally due to an unrecoverable error."); + } } // Set value of the 'pipe' property. if (!empty($this->return_property)) {