captainhook
captainhook copied to clipboard
Configuration can not be recogonized correctly whild multiple placeholder in one command
eg:
{"action": "{$config|value-of:php-path} {$config|value-of:composer-path} install"}
ps: composer-path is already defined
code for find placeholders:
/**
* Returns al list of all placeholders
*
* @param string $command
* @return array<int, string>
*/
private function findAllPlaceholders(string $command): array
{
$placeholders = [];
$matches = [];
if (preg_match_all('#{\$([a-z_]+(\|[a-z\-]+:.*)?)}#i', $command, $matches)) {
foreach ($matches[1] as $match) {
$placeholders[] = $match;
}
}
return $placeholders;
}
Output:
$placeholders = ['config|value-of:php-path} {$config|value-of:composer-path'];
What I really expected:
$placeholders = ['config|value-of:php-path', 'config|value-of:composer-path'];
Sorry, My captainhook version is too old...
On a first glance I could not find a unit test covering that functionality.
I will add one just for my inner peace :)
Glad an update fixed your issue.