Skip to content

Commit

Permalink
Interactive: In case of error kill whole process.
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek authored Feb 25, 2020
1 parent bb222f9 commit 29a62f3
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/InteractiveComposer/InteractiveComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ public function __construct(PackageRegistrator $packageRegistrator)

public function run(): void
{
$errorTasks = [];

foreach ($this->getTasks() as $taskClass) {
echo "\n" . str_repeat('-', 100) . "\n";

Expand All @@ -37,28 +35,20 @@ public function run(): void
if ($task->run() === true) {
echo "\n\n" . '👍 ' . "\e[1;33;40m" . 'Task was successful. 👍' . "\e[0m";
} else {
$errorTasks[] = $taskClass;
echo "\n\n" . 'Task error.';
echo "\n\n";
Helpers::terminalRenderError('Task "' . $taskClass . '" failed!');
echo "\n\n";
die;
}
} catch (TaskException|\RuntimeException $e) {
$errorTasks[] = $taskClass;
echo "\n\n" . 'Task error (' . $e->getMessage() . ').';
}
}

echo "\n" . str_repeat('-', 100) . "\n\n\n";

if (\count($errorTasks) > 0) {
echo 'Error tasks:' . "\n\n";

foreach ($errorTasks as $errorTask) {
echo '- ' . $errorTask . "\n";
echo "\n\n";
Helpers::terminalRenderError('Task "' . $taskClass . '" failed!' . "\n\n" . $e->getMessage());
echo "\n\n";
die;
}
} else {
echo 'All tasks was OK.';
}

echo "\n\n\n";
echo "\n" . str_repeat('-', 100) . "\n\n\n" . 'All tasks was OK.' . "\n\n\n";
}

/**
Expand Down

0 comments on commit 29a62f3

Please sign in to comment.