Skip to content

Commit

Permalink
Merge pull request #14 from heiglandreas/addRenameFile
Browse files Browse the repository at this point in the history
Add possibility to set name for downloaded files
  • Loading branch information
tommy-muehle authored Mar 4, 2019
2 parents bafde05 + 60ef21d commit 6e69db1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Factory/ToolFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function createTool($name, $directory, array $parameters)
'sign-url' => null,
'only-dev' => true,
'force-replace' => false,
'rename' => false,
];

$parameters = array_merge($defaults, $parameters);
Expand All @@ -42,6 +43,10 @@ public static function createTool($name, $directory, array $parameters)
$tool->disableOnlyDev();
}

if (true === $parameters['rename']) {
$tool->setNameToToolKey();
}

return $tool;
}

Expand Down
21 changes: 21 additions & 0 deletions src/Model/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Tool
*/
private $onlyDev = true;

/**
* @var bool
*/
private $rename = false;

/**
* @param string $name
* @param string $filename
Expand Down Expand Up @@ -116,4 +121,20 @@ public function forceReplace()
{
return $this->forceReplace;
}

/**
* @return void
*/
public function setNameToToolKey()
{
$this->rename = true;
}

/**
* @return bool
*/
public function renameToConfigKey()
{
return $this->rename;
}
}
3 changes: 3 additions & 0 deletions src/Script/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public function symlinkOrCopy(Tool $tool)
}

$filename = $tool->getFilename();
if ($tool->renameToConfigKey()) {
$filename = $tool->getName();
}
$composerDir = $this->configuration->getComposerBinDirectory();
$composerPath = $composerDir . DIRECTORY_SEPARATOR . basename($filename);

Expand Down

0 comments on commit 6e69db1

Please sign in to comment.