Skip to content

Commit dd41567

Browse files
Allow calling stories from other stories (#287)
* Allow calling stories from other stories fixes #149 * Fix Style CI + phpstan * Fix StyleCI * Update RunCommand.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 3c32f35 commit dd41567

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Console/RunCommand.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,28 @@ protected function fire()
105105
*/
106106
protected function getTasks($container)
107107
{
108-
$tasks = [$task = $this->argument('task')];
108+
return $this->buildTaskList($container, $this->argument('task'));
109+
}
109110

111+
/**
112+
* Build a list of tasks starting from a task or macro name.
113+
*
114+
* @param array $tasks
115+
* @param \Laravel\Envoy\TaskContainer $container
116+
* @param string $task
117+
* @return array
118+
*/
119+
protected function buildTaskList($container, $task, $tasks = []): array
120+
{
110121
if ($macro = $container->getMacro($task)) {
111-
$tasks = $macro;
122+
foreach ($macro as $task) {
123+
$tasks = $this->buildTaskList($container, $task, $tasks);
124+
}
125+
126+
return $tasks;
112127
}
113128

114-
return $tasks;
129+
return [...$tasks, $task];
115130
}
116131

117132
/**

0 commit comments

Comments
 (0)