Skip to content

Commit

Permalink
Added exclude option on copying tasks. Closes consolidation#327
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed May 21, 2016
1 parent 847ed33 commit 2869be4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Task/Filesystem/CopyDir.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class CopyDir extends BaseDir
/** @var int $chmod */
protected $chmod = 0755;

/**
* @var array files to exclude on copying
*/
protected $exclude = [];

public function run()
{
if (!$this->checkResources($this->dirs, 'dir')) {
Expand Down Expand Up @@ -50,6 +55,18 @@ public function dirPermissions($value)
return $this;
}

/**
* List files to exclude.
*
* @param array $exclude
* @return $this
*/
public function exclude($exclude = [])
{
$this->exclude = $exclude;
return $this;
}

/**
* Copies a directory to another location.
*
Expand All @@ -68,6 +85,9 @@ protected function copyDir($src, $dst)
mkdir($dst, $this->chmod, true);
}
while (false !== ($file = readdir($dir))) {
if (in_array($file, $this->exclude)) {
continue;
}
if (($file !== '.') && ($file !== '..')) {
$srcFile = $src . '/' . $file;
$destFile = $dst . '/' . $file;
Expand Down

0 comments on commit 2869be4

Please sign in to comment.