* @package PHPCI * @subpackage Plugins */ class CopyBuild implements \PHPCI\Plugin { protected $directory; protected $ignore; protected $phpci; public function __construct(Builder $phpci, Build $build, array $options = array()) { $path = $phpci->buildPath; $this->phpci = $phpci; $this->directory = isset($options['directory']) ? $options['directory'] : $path; $this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; } /** * Copies files from the root of the build directory into the target folder */ public function execute() { $build = $this->phpci->buildPath; if ($this->directory == $build) { return false; } $cmd = 'mkdir -p "%s" && cp -R "%s" "%s"'; $success = $this->phpci->executeCommand($cmd, $this->directory, $build, $this->directory); if ($this->ignore) { foreach ($this->phpci->ignore as $file) { $cmd = 'rm -Rf "%s/%s"'; $this->phpci->executeCommand($cmd, $this->directory, $file); } } return $success; } }