From 36969165a07f2893b00761f6b3a33162b659a631 Mon Sep 17 00:00:00 2001 From: Uhkis Date: Wed, 2 Oct 2013 14:28:33 +0300 Subject: [PATCH 1/5] Fail on drush unrecovable error. --- DrushTask.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DrushTask.php b/DrushTask.php index d0e28e5..ba58013 100644 --- a/DrushTask.php +++ b/DrushTask.php @@ -268,6 +268,9 @@ public function main() { exec($command, $output, $return); // Collect Drush output for display through Phing's log. foreach ($output as $line) { + if ($this->haltonerror && preg_match_all('/Drush command terminated abnormally due to an unrecoverable error./', $line)) { + throw new BuildException("Drush command terminated abnormally due to an unrecoverable error."); + } $this->log($line); } // Set value of the 'pipe' property. From 567bf70fa95f137cdd9b751ef1c64e60150b76ef Mon Sep 17 00:00:00 2001 From: Uhkis Date: Wed, 2 Oct 2013 15:02:25 +0300 Subject: [PATCH 2/5] Read from stderr and switch to strpos --- DrushTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DrushTask.php b/DrushTask.php index ba58013..29ac830 100644 --- a/DrushTask.php +++ b/DrushTask.php @@ -265,10 +265,10 @@ 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) { - if ($this->haltonerror && preg_match_all('/Drush command terminated abnormally due to an unrecoverable error./', $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."); } $this->log($line); From 3c1947a0ce14df8505ed3339207e347a65edbe4f Mon Sep 17 00:00:00 2001 From: Uhkis Date: Thu, 3 Oct 2013 08:12:50 +0300 Subject: [PATCH 3/5] Log before throwing exception. --- DrushTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DrushTask.php b/DrushTask.php index 29ac830..9f5ee2d 100644 --- a/DrushTask.php +++ b/DrushTask.php @@ -268,10 +268,10 @@ public function main() { 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."); } - $this->log($line); } // Set value of the 'pipe' property. if (!empty($this->return_property)) { From 3ddc6e0ea99b3fd249ad9e8175df9b39a571bad7 Mon Sep 17 00:00:00 2001 From: Uhkis Date: Mon, 7 Oct 2013 11:16:58 +0300 Subject: [PATCH 4/5] Add possibility to use site alias. --- DrushTask.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/DrushTask.php b/DrushTask.php index 9f5ee2d..0af5368 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)) { + $option = new DrushOption(); + $option->addText($this->site_alias); + $this->options[] = $option; + } + + if (!empty($this->root) && empty($this->site_alias)) { $option = new DrushOption(); $option->setName('root'); $option->addText($this->root); From 6d2ef4503ff8bd66d5d5fc7ac8ad169fbde16466 Mon Sep 17 00:00:00 2001 From: Uhkis Date: Mon, 7 Oct 2013 11:27:56 +0300 Subject: [PATCH 5/5] Param instead of Option class for site alias. --- DrushTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DrushTask.php b/DrushTask.php index 0af5368..4c73e2b 100644 --- a/DrushTask.php +++ b/DrushTask.php @@ -219,9 +219,9 @@ public function main() { $this->options[] = $option; if (!empty($this->site_alias)) { - $option = new DrushOption(); - $option->addText($this->site_alias); - $this->options[] = $option; + $param = new DrushParam(); + $param->addText($this->site_alias); + $command[] = $param->getValue(); } if (!empty($this->root) && empty($this->site_alias)) {