From 08af69341de43b7cbbe0d7c832a5f59e1d60b70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1gi-Kaz=C3=A1r=20M=C3=A1rk?= Date: Thu, 12 Mar 2015 18:18:04 +0100 Subject: [PATCH] Adds environment support to Exec task --- src/Task/Base/Exec.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Task/Base/Exec.php b/src/Task/Base/Exec.php index 0ca8c5f3d..10bf6b7ec 100644 --- a/src/Task/Base/Exec.php +++ b/src/Task/Base/Exec.php @@ -36,6 +36,7 @@ class Exec extends BaseTask implements CommandInterface, PrintedInterface protected $background = false; protected $timeout = null; protected $idleTimeout = null; + protected $env = null; /** * @var Process @@ -88,6 +89,18 @@ public function idleTimeout($timeout) return $this; } + /** + * Sets the environment variables for the command + * + * @param $env + * @return $this + */ + public function env(array $env) + { + $this->env = $env; + return $this; + } + public function __destruct() { $this->stop(); @@ -111,6 +124,10 @@ public function run() $this->process->setIdleTimeout($this->idleTimeout); $this->process->setWorkingDirectory($this->workingDirectory); + if (isset($this->env)) { + $this->process->setEnv($this->env); + } + if (!$this->background and !$this->isPrinted) { $this->startTimer(); $this->process->run();