Skip to content
This repository was archived by the owner on Mar 9, 2024. It is now read-only.

Split patterns for single globs (should be max 260 chars) #6

Merged
merged 2 commits into from
Jun 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/CleanupPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ protected function cleanPackage(BasePackage $package)
$packageName = $package->getPrettyName();
$packageDir = $targetDir ? $packageName . '/' . $targetDir : $packageName ;

$rule = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;
if(!$rule){
$rules = isset($this->rules[$packageName]) ? $this->rules[$packageName] : null;
if(!$rules){
return;
}

Expand All @@ -126,15 +126,18 @@ protected function cleanPackage(BasePackage $package)
return false;
}

foreach((array) $rule as $part) {
// Make 1 pattern, surrounded by braces, should be max 260 chars
$pattern = '{' . implode(',', explode(' ', $part)) . '}';
try {
foreach (glob($dir.'/'.$pattern, GLOB_BRACE) as $file) {
$this->filesystem->remove($file);
foreach((array) $rules as $part) {
// Split patterns for single globs (should be max 260 chars)
$patterns = explode(' ', trim($part));

foreach ($patterns as $pattern) {
try {
foreach (glob($dir.'/'.$pattern) as $file) {
$this->filesystem->remove($file);
}
} catch (\Exception $e) {
$this->io->write("Could not parse $packageDir ($pattern): ".$e->getMessage());
}
} catch (\Exception $e) {
$this->io->write("Could not parse $packageDir ($pattern): ".$e->getMessage());
}
}

Expand Down