Skip to content

Commit 9c9208e

Browse files
authored
Merge pull request #201 from ByteInternet/Only-build-AfterTasks-that-are-Commands
Only execute AfterTasks that are Commands in the Commands-flow
2 parents dd6f46f + f3638a3 commit 9c9208e

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/Deployer/Task/After/AfterTaskGlobal.php‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use Hypernode\Deploy\Deployer\Task\TaskBase;
66
use Hypernode\Deploy\Deployer\TaskBuilder;
7+
use Hypernode\DeployConfiguration\Command\Command;
78
use Hypernode\DeployConfiguration\Configuration;
9+
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
810

911
use function count;
1012
use function Deployer\task;
@@ -24,7 +26,12 @@ public function __construct(TaskBuilder $taskBuilder)
2426

2527
public function configure(Configuration $config): void
2628
{
27-
$tasks = $this->taskBuilder->buildAll($config->getAfterDeployTasks(), 'deploy:after');
29+
$commands = array_values(array_filter(
30+
$config->getAfterDeployTasks(),
31+
fn (TaskConfigurationInterface $task): bool => $task instanceof Command
32+
));
33+
34+
$tasks = $this->taskBuilder->buildAll($commands, 'deploy:after');
2835
if (count($tasks) === 0) {
2936
$tasks = function (): void {
3037
writeln('No after deploy tasks defined');

‎src/Deployer/TaskBuilder.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class TaskBuilder
2020
{
2121
/**
22-
* @param TaskConfigurationInterface[] $commands
22+
* @param Command[] $commands
2323
*
2424
* @param string $namePrefix
2525
* @return string[]
@@ -32,7 +32,6 @@ public function buildAll(array $commands, string $namePrefix): array
3232
foreach ($commands as $command) {
3333
$name = $namePrefix . ':' . \count($tasks);
3434

35-
/** @var Command $command */
3635
$this->build($command, $name);
3736

3837
$tasks[] = $name;

0 commit comments

Comments
 (0)