Deployer: Parse also the vars with `:` like the task names `deploy:prepare`, `deploy:lock`

Created on 2 Apr 2017  路  4Comments  路  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Feature Request
| Deployer Version | 4.3.0
| Local Machine OS | N/A
| Remote Machine OS | N/A

Description

I want to do run({{nginx:restart}}) inside a task like this:

task('predeploy:nginx', function () {
    if(!commandExist('nginx')) {
        // ...

        // restart nginx
        run('{{nginx:restart}}');
    }

    return get('bin/nginx');
});

i set the nginx:restart var like this:

// Closures
$nginxRestart = function () {
    return run('sudo systemctl restart nginx');
};
set('nginx:restart', $nginxRestart);

I use a closure because i have also an nginx:restart task:

task('nginx:restart', $nginxRestart);

If i replace {{nginx:restart}} by {{nginx-restart}} it works but not with the : char.
I take a look at the parse function used, the regex doesn't accept the : char.
The same pattern task:subtask is used in the task name, is it possible to update the parse regex for var names from this /\{\{\s*([\w\.\/-]+)\s*\}\}/ to this \{\{\s*([\w\:\.\/-]+)\s*\}\} ?

I can create a PR.

Thanks

Most helpful comment

Why not run('{{nginx:restart}}'); to nginxRestart();?
In v5 there is invoke('task') func.

All 4 comments

Why not run('{{nginx:restart}}'); to nginxRestart();?
In v5 there is invoke('task') func.

In v5 there is invoke('task') func.

Do you mean that in v5 it will not be possible to use mustache syntax {{var}} inside the run function ?

No

For know i think to close this issue. If there will be need or real use case lets talk about it again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

greatwitenorth picture greatwitenorth  路  4Comments

lsv picture lsv  路  4Comments

brunodevel picture brunodevel  路  3Comments

osbulbul picture osbulbul  路  3Comments

ElForastero picture ElForastero  路  3Comments