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();