Beispiel #1
0
 /**
  * Execute the task
  *
  * @return PhpScript
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFile()) {
         throw new BuildException("File not set");
     }
     $file = $this->getProperties()->filter($this->getFile());
     Pale::run(function () use($file) {
         require $file;
     });
     return $this;
 }
Beispiel #2
0
 /**
  * Execute the task
  *
  * @return self
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getDirectory()) {
         throw new BuildException('Directory is not set');
     }
     $directory = $this->properties->filter($this->getDirectory());
     Pale::run(function () use($directory) {
         return chdir($directory);
     });
     return $this;
 }
Beispiel #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;
 }
Beispiel #4
0
 public function testErrorHandlerIsRestored()
 {
     set_error_handler(function () {
         throw new Exception("external");
     });
     try {
         Pale::run(function () {
             trigger_error("internal");
         });
         $this->fail();
     } catch (ErrorException $e) {
         $this->assertEquals("internal", $e->getMessage());
     }
     try {
         trigger_error("test");
         $this->fail();
     } catch (Exception $e) {
         $this->assertEquals("external", $e->getMessage());
     }
 }
Beispiel #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;
 }
Beispiel #6
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;
 }
Beispiel #7
0
 /**
  * Setup the base directory
  *
  * @return Project
  */
 protected function setupBaseDirectory()
 {
     if ($this->getBaseDirectory()) {
         $project = $this;
         Pale::run(function () use($project) {
             return chdir($project->getBaseDirectory());
         });
     }
     return $this;
 }
Beispiel #8
0
 /**
  * Execute the task
  *
  * @return self
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFiles()) {
         throw new BuildException("Files are not set");
     }
     if (!$this->getGroup()) {
         throw new BuildException("Group is not set");
     }
     $group = $this->properties->filter($this->getGroup());
     foreach ($this->getFiles() as $file) {
         $file = $this->properties->filter($file);
         Pale::run(function () use($file, $group) {
             return chgrp($file, $group);
         });
     }
     return $this;
 }
Beispiel #9
0
 /**
  * Execute the task
  *
  * @return self
  * @throw BuildException
  */
 public function execute()
 {
     if (!$this->getStandard()) {
         throw new BuildException("No standard set");
     }
     if (!class_exists("CodeSniffer")) {
         Pale::run(function () {
             require_once "PHP/CodeSniffer.php";
         });
     }
     if (CodeSniffer::isInstalledStandard($this->getStandard()) === false) {
         throw new BuildException("Invalid standard name");
     }
     // Clear out argv so PHP_CodeSniffer doesn"t freak out
     $oldArgv = $SERVER["argv"];
     $SERVER["argv"] = array();
     $SERVER["argc"] = 0;
     // Get the current working directory because PHP_CodeSniffer will change it
     $cwd = getcwd();
     $codeSniffer = new CodeSniffer(0, 0, "UTF-8");
     $codeSniffer->process($this->getFiles(), $this->filterProperties($this->getStandard()));
     // Restore the argv/c superglobals
     $SERVER["argv"] = $oldArgv;
     $SERVER["argc"] = count($oldArgv);
     // Reset the current working directory
     chdir($cwd);
     $filesViolations = $codeSniffer->getFilesErrors();
     $reporting = new Reporting();
     $report = $reporting->prepare($filesViolations, $this->getShowWarnings());
     $reporting->printReport($this->getReportType(), $filesViolations, $this->getShowSources(), $this->getReportFile(), $this->getReportWidth());
     return $this;
 }
Beispiel #10
0
 /**
  * Execute the task
  *
  * @return self 
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getLink()) {
         throw new BuildException("Link not set");
     }
     if (!$this->getTarget()) {
         throw new BuildException("Target not set");
     }
     $target = $this->getProperties()->filter($this->getTarget());
     $link = $this->getProperties()->filter($this->getLink());
     Pale::run(function () use($target, $link) {
         return symlink($target, $link);
     });
     return $this;
 }
Beispiel #11
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;
 }
Beispiel #12
0
 /**
  * Execute the task
  *
  * @return self
  * @throw BuildException
  */
 public function execute()
 {
     if (!$this->getFile()) {
         throw new BuildException("File not set");
     }
     if (!$this->getDestination()) {
         throw new BuildException("Destination not set");
     }
     $file = $this->getProperties()->filter($this->getFile());
     $destination = $this->getProperties()->filter($this->getDestination());
     Pale::run(function () use($file, $destination) {
         return rename($file, $destination);
     });
     return $this;
 }
Beispiel #13
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;
 }
Beispiel #14
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;
 }
Beispiel #15
0
 /**
  * Execute the task
  *
  * @return self
  * @throws BuildException
  */
 public function execute()
 {
     if (!$this->getFiles()) {
         throw new BuildException("Files are not set");
     }
     if (!$this->getMode()) {
         throw new BuildException("Mode is not set");
     }
     $mode = $this->properties->filter($this->getMode());
     if (is_string($mode)) {
         $mode = octdec($mode);
     }
     foreach ($this->getFiles() as $file) {
         $file = $this->properties->filter($file);
         Pale::run(function () use($file, $mode) {
             return chmod($file, $mode);
         });
     }
     return $this;
 }