Skip to content

Commit

Permalink
Added tag replacement to path names
Browse files Browse the repository at this point in the history
Any all-caps instance of a tag in a path gets replaced with the
relevant tag.

For the project “TestProject” /src/NAME turns into /src/TestProject.
  • Loading branch information
tedivm committed Jun 27, 2014
1 parent dd55263 commit 5acdd74
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Spark/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@ protected function makeFiles($base, $tags)

protected function getTemplateFiles($tags)
{
$name = isset($tags['name']) ? $tags['name'] : 'PROJECTNAME';

$plugins = $this->plugins;
$pluginPath = $this->pluginPath;

$tagName = array();
$tagValue = array();
foreach($tags as $name => $value) {
$tagName[] = strtoupper($name);
$tagValue[] = $value;
}


foreach ($plugins as $plugin) {
$path = $pluginPath . $plugin;
$this->templateSourceDirectories[] = $path;
Expand All @@ -77,7 +83,7 @@ protected function getTemplateFiles($tags)

foreach ($finder as $file) {
$longPath = $file->getRealpath();
$processedPath = str_replace('PROJECTNAME', $name, $longPath);
$processedPath = str_replace($tagName, $tagValue, $longPath);
$shortPath = substr($processedPath, $pathLen + 1);
if ($file->isDir()) {
$this->outputDirectories[] = $shortPath;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5acdd74

Please sign in to comment.