From f12b8492b832dbcc404b24a86449b23e241b4878 Mon Sep 17 00:00:00 2001 From: nuvolapl Date: Fri, 16 Aug 2019 14:30:16 +0200 Subject: [PATCH] Added possibility to decorate shell command --- src/Server/Property.php | 1 + src/Task/TaskRunner.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Server/Property.php b/src/Server/Property.php index 8ac7580..ced0f84 100644 --- a/src/Server/Property.php +++ b/src/Server/Property.php @@ -22,6 +22,7 @@ final class Property { const bin_dir = 'bin_dir'; + const command_decorator = 'command_decorator'; const config_dir = 'config_dir'; const console_bin = 'console_bin'; const cache_dir = 'cache_dir'; diff --git a/src/Task/TaskRunner.php b/src/Task/TaskRunner.php index 5189dba..b2ead4a 100644 --- a/src/Task/TaskRunner.php +++ b/src/Task/TaskRunner.php @@ -56,6 +56,10 @@ private function doRun(Server $server, string $shellCommand, array $envVars): Ta $shellCommand = sprintf('(export %s; %s)', $envVarsAsString, $shellCommand); } + if ($server->has(Property::command_decorator)) { + $shellCommand = $this->applyCommandDecorator($server->get(Property::command_decorator), $server, $shellCommand, $envVars); + } + $this->logger->log(sprintf('[%s] Executing command: %s', $server, $shellCommand)); if ($this->isDryRun) { @@ -80,4 +84,9 @@ private function doRun(Server $server, string $shellCommand, array $envVars): Ta return new TaskCompleted($server, $process->getOutput(), $process->getExitCode()); } + + private function applyCommandDecorator(callable $decorator, Server $server, string $shellCommand, array $envVars): string + { + return $decorator($server, $shellCommand, $envVars); + } }