Skip to content
This repository was archived by the owner on Sep 6, 2020. It is now read-only.

Faster adding of files if they match any of the excluded regexps #147

Open
wants to merge 9 commits into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions res/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
},
"type": ["array", "string"]
},
"exclude-from-value-replace": {
"description": "A list of regular expressions for file paths to not value replace but add verbatim",
"items": {
"type": "string"
},
"type": ["array", "string"]
},
"bootstrap": {
"description": "A file used to load third-party class compactors.",
"type": "string"
Expand Down
9 changes: 9 additions & 0 deletions src/lib/KevinGH/Box/Command/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ protected function execute(InputInterface $input, OutputInterface $output)

unset($values, $key, $value);
}
//set the regular expressions for files that don't need value replacement
if (array() !== ($excludedFromValueReplace = $this->config->getExcludedFromValueReplace())) {
$this->box->setExcludedFromValueReplace($excludedFromValueReplace, $this->config->getBasePath());
}



// register configured compactors
if (array() !== ($compactors = $this->config->getCompactors())) {
Expand Down Expand Up @@ -695,6 +701,9 @@ private function add(

$box->addFile($file, $relative);
}
if($box instanceof Box) {
$box->addFilesFromQueue();
}
}
}
}
12 changes: 12 additions & 0 deletions src/lib/KevinGH/Box/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ function (&$file) {
return array();
}

/**
* Returns a list of non parsed regular expressions to exclude files from getting replacements
*
* @return array
*/
public function getExcludedFromValueReplace()
{
if (isset($this->raw->{'exclude-from-value-replace'})) {
return (array)$this->raw->{'exclude-from-value-replace'};
}
return array();
}
/**
* Returns a filter callable for the configured blacklist.
*
Expand Down