/** * @return \Composer\Config */ public static function loadConfiguration() { try { $configuration = Factory::createConfig(); } catch (Exception $e) { throw RuntimeException::fromAnyException($e); } return $configuration; }
/** * @param TaskInterface $task * @param ContextInterface $context * * @return TaskResultInterface * @throws RuntimeException */ private function runTask(TaskInterface $task, ContextInterface $context) { try { $this->eventDispatcher->dispatch(TaskEvents::TASK_RUN, new TaskEvent($task, $context)); $result = $task->run($context); } catch (RuntimeException $e) { $result = TaskResult::createFailed($task, $context, $e->getMessage()); } if (!$result instanceof TaskResultInterface) { throw RuntimeException::invalidTaskReturnType($task); } if (!$result->isPassed() && !$this->grumPHP->isBlockingTask($task->getName())) { $result = TaskResult::createNonBlockingFailed($result->getTask(), $result->getContext(), $result->getMessage()); } if (!$result->isPassed()) { $e = new RuntimeException($result->getMessage()); $this->eventDispatcher->dispatch(TaskEvents::TASK_FAILED, new TaskFailedEvent($task, $context, $e)); return $result; } $this->eventDispatcher->dispatch(TaskEvents::TASK_COMPLETE, new TaskEvent($task, $context)); return $result; }