captainhook icon indicating copy to clipboard operation
captainhook copied to clipboard

Configuration can not be recogonized correctly whild multiple placeholder in one command

Open wksama opened this issue 4 years ago • 2 comments

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'];

wksama avatar Dec 14 '21 10:12 wksama

Sorry, My captainhook version is too old...

wksama avatar Dec 14 '21 10:12 wksama

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.

sebastianfeldmann avatar Dec 14 '21 10:12 sebastianfeldmann