Skip to content

Commit

Permalink
Make cd work in yaml recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Nov 13, 2020
1 parent c7542ec commit 1d137ad
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/Importer/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -115,7 +116,11 @@ protected static function tasks($tasks)
$wrapRun($script);
} else {
foreach ($script as $line) {
$wrapRun($line);
if (preg_match('/^cd\s(?<path>.+)/i', $line, $matches)) {
cd($matches['path']);
} else {
$wrapRun($line);
}
}
}
};
Expand Down Expand Up @@ -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);
}
}
}
}

0 comments on commit 1d137ad

Please sign in to comment.