Skip to content

Commit

Permalink
Adds environment support to Exec task
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Mar 12, 2015
1 parent 49a91e0 commit 08af693
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Task/Base/Exec.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 08af693

Please sign in to comment.