From 1d137ad0addf2f6ce5e9b42063132afbfd7b96e2 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Fri, 13 Nov 2020 21:07:06 +0100 Subject: [PATCH] Make cd work in yaml recipes --- src/Importer/Importer.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Importer/Importer.php b/src/Importer/Importer.php index 7ac8d67df..5ddc86cf0 100644 --- a/src/Importer/Importer.php +++ b/src/Importer/Importer.php @@ -11,6 +11,7 @@ use Symfony\Component\Yaml\Yaml; use function Deployer\after; use function Deployer\before; +use function Deployer\cd; use function Deployer\download; use function Deployer\host; use function Deployer\localhost; @@ -115,7 +116,11 @@ protected static function tasks($tasks) $wrapRun($script); } else { foreach ($script as $line) { - $wrapRun($line); + if (preg_match('/^cd\s(?.+)/i', $line, $matches)) { + cd($matches['path']); + } else { + $wrapRun($line); + } } } }; @@ -181,14 +186,26 @@ protected static function tasks($tasks) protected static function after($after) { foreach ($after as $key => $value) { - after($key, $value); + if (is_array($value)) { + foreach (array_reverse($value) as $v) { + after($key, $v); + } + } else { + after($key, $value); + } } } protected static function before($before) { foreach ($before as $key => $value) { - before($key, $value); + if (is_array($value)) { + foreach (array_reverse($value) as $v) { + before($key, $v); + } + } else { + before($key, $value); + } } } }