Example #1
0
 /**
  * Execute the task
  *
  * @return Exec
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getCommand()) {
         throw new BuildException('Command is not set');
     }
     $command = $this->properties->filter($this->getCommand());
     $directory = $this->properties->filter($this->getDirectory());
     $result = Pale::run(function () use($command, $directory) {
         $descriptorSpec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
         $process = proc_open($command, $descriptorSpec, $pipes, $directory);
         if (!$process) {
             throw new CommandFailedException($command, $directory);
         }
         fclose($pipes[0]);
         $stdout = stream_get_contents($pipes[1]);
         fclose($pipes[1]);
         $stderr = stream_get_contents($pipes[2]);
         fclose($pipes[2]);
         $return = proc_close($process);
         return array('stdout' => $stdout, 'stderr' => $stderr, 'return' => $return);
     });
     if ($result['return']) {
         throw new CommandReturnedErrorException($command, $directory, $result['return'], $result['stdout'], $result['stderr']);
     }
     return $this;
 }
Example #2
0
 /**
  * Execute the task
  *
  * @return Touch
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFile()) {
         throw new BuildException("File not set");
     }
     $file = $this->properties->filter($this->getFile());
     $time = $this->properties->filter($this->getTime());
     Pale::run(function () use($file, $time) {
         return touch($file, $time);
     });
     return $this;
 }
Example #3
0
 /**
  * Execute the task
  *
  * @return self
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFiles()) {
         throw new BuildException("Files are not set");
     }
     foreach ($this->files as $file) {
         $file = $this->properties->filter($file);
         Pale::run(function () use($file) {
             return unlink($file);
         });
     }
     return $this;
 }
Example #4
0
 /**
  * Execute the task
  *
  * @return Input
  */
 public function execute()
 {
     if (!$this->getPropertyName()) {
         throw new BuildException('Property name not set');
     }
     if ($this->getMessage()) {
         fwrite($this->getOutputStream(), $this->properties->filter($this->getMessage()));
     }
     $validArgs = array();
     foreach ($this->getValidArgs() as $validArg) {
         $validArgs[] = $this->properties->filter($validArg);
     }
     if ($validArgs) {
         fwrite($this->getOutputStream(), ' [' . implode('/', $validArgs) . ']');
     }
     fwrite($this->getOutputStream(), $this->properties->filter($this->getPromptCharacter()) . ' ');
     $value = trim(fgets($this->getInputStream()));
     if (trim($value) == '') {
         $value = $this->properties->filter($this->getDefaultValue());
     }
     if ($validArgs && !in_array($value, $validArgs)) {
         throw new BuildException('Invalid argument');
     }
     $this->properties->{$this->getPropertyName()} = $value;
     return $this;
 }
Example #5
0
 /**
  * Execute the task
  *
  * @return Copy
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFile()) {
         throw new BuildException('File is not set');
     }
     if (!$this->getDestination()) {
         throw new BuildException('Destination is not set');
     }
     $file = $this->properties->filter($this->getFile());
     $destination = $this->properties->filter($this->getDestination());
     Pale::run(function () use($file, $destination) {
         return copy($file, $destination);
     });
     return $this;
 }
Example #6
0
 /**
  * Execute the task
  *
  * @return Chown
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFiles()) {
         throw new BuildException("Files are not set");
     }
     if (!$this->getOwner()) {
         throw new BuildException("Owner is not set");
     }
     $owner = $this->properties->filter($this->getOwner());
     foreach ($this->getFiles() as $file) {
         $file = $this->properties->filter($file);
         Pale::run(function () use($file, $owner) {
             return chown($file, $owner);
         });
     }
     return $this;
 }
Example #7
0
 /**
  * Execute the task
  *
  * @return self 
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFile()) {
         throw new BuildException("File not set");
     }
     $endingCharacter = $this->properties->filter($this->getEndingCharacter());
     $file = $this->properties->filter($this->getFile());
     $replacements = $this->getReplacements();
     $startingCharacter = $this->properties->filter($this->getStartingCharacter());
     Pale::run(function () use($file, $replacements, $endingCharacter, $startingCharacter) {
         $contents = file_get_contents($file);
         foreach ($replacements as $token => $value) {
             $contents = str_replace($endingCharacter . $token . $startingCharacter, $value, $contents);
         }
         return file_put_contents($file, $contents);
     });
     return $this;
 }