This commit is contained in:
Greg J Preece 2016-12-02 13:58:21 +00:00 committed by GitHub
commit fb6ade2f3f

View file

@ -26,6 +26,7 @@ class CopyBuild implements \PHPCI\Plugin
protected $wipe; protected $wipe;
protected $phpci; protected $phpci;
protected $build; protected $build;
protected $includeDir;
/** /**
* Set up the plugin, configure options, etc. * Set up the plugin, configure options, etc.
@ -35,12 +36,13 @@ class CopyBuild implements \PHPCI\Plugin
*/ */
public function __construct(Builder $phpci, Build $build, array $options = array()) public function __construct(Builder $phpci, Build $build, array $options = array())
{ {
$path = $phpci->buildPath; $path = $phpci->buildPath;
$this->phpci = $phpci; $this->phpci = $phpci;
$this->build = $build; $this->build = $build;
$this->directory = isset($options['directory']) ? $options['directory'] : $path; $this->directory = isset($options['directory']) ? $options['directory'] : $path;
$this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false; $this->includeDir = isset($options['include_build_dir']) ? $options['include_build_dir'] : true;
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false; $this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false;
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false;
} }
/** /**
@ -48,6 +50,7 @@ class CopyBuild implements \PHPCI\Plugin
*/ */
public function execute() public function execute()
{ {
$build = $this->phpci->buildPath; $build = $this->phpci->buildPath;
if ($this->directory == $build) { if ($this->directory == $build) {
@ -56,9 +59,20 @@ class CopyBuild implements \PHPCI\Plugin
$this->wipeExistingDirectory(); $this->wipeExistingDirectory();
$cmd = 'mkdir -p "%s" && cp -R "%s" "%s"'; $suffix = '';
if ($this->includeDir == false) {
if (substr($build, -1) != DIRECTORY_SEPARATOR) {
$build .= DIRECTORY_SEPARATOR;
}
$suffix = "*";
}
$cmd = 'mkdir -p "%s" && cp -R "%s"' . $suffix . ' "%s"';
if (IS_WIN) { if (IS_WIN) {
$cmd = 'mkdir -p "%s" && xcopy /E "%s" "%s"'; $cmd = 'mkdir -p "%s" && xcopy /E "%s' . $suffix . '" "%s"';
} }
$success = $this->phpci->executeCommand($cmd, $this->directory, $build, $this->directory); $success = $this->phpci->executeCommand($cmd, $this->directory, $build, $this->directory);