Example #1
0
 /**
  * @param ContextInterface $context
  *
  * @return int
  */
 public function run(OutputInterface $output, ContextInterface $context)
 {
     try {
         $this->taskRunner->run($context);
     } catch (ExceptionInterface $e) {
         // We'll fail hard on any exception not generated in GrumPHP
         return $this->returnErrorMessage($output, $e->getMessage());
     }
     return $this->returnSuccessMessage($output);
 }
Example #2
0
 /**
  * @param OutputInterface  $output
  * @param ContextInterface $context
  * @param bool|false       $skipSuccessOutput
  *
  * @return int
  */
 public function run(OutputInterface $output, ContextInterface $context, $skipSuccessOutput = false)
 {
     try {
         $this->taskRunner->run($context);
     } catch (ExceptionInterface $e) {
         // We'll fail hard on any exception not generated in GrumPHP
         return $this->returnErrorMessage($output, $e->getMessage());
     }
     // Skip before returning any messages
     if ($skipSuccessOutput) {
         return self::CODE_SUCCESS;
     }
     return $this->returnSuccessMessage($output);
 }
Example #3
0
 /**
  * @param OutputInterface  $output
  * @param ContextInterface $context
  * @param bool|false       $skipSuccessOutput
  *
  * @return int
  */
 public function run(OutputInterface $output, ContextInterface $context, $skipSuccessOutput = false)
 {
     // Make sure to add some default event listeners before running.
     $this->registerEventListeners($output, $context);
     $taskResults = $this->taskRunner->run($context);
     $warnings = $taskResults->filterByResultCode(TaskResult::NONBLOCKING_FAILED);
     if ($taskResults->isFailed()) {
         $failed = $taskResults->filterByResultCode(TaskResult::FAILED);
         return $this->returnErrorMessages($output, $failed->getAllMessages(), $warnings->getAllMessages());
     }
     if ($skipSuccessOutput) {
         $this->returnWarningMessages($output, $warnings->getAllMessages());
         return self::CODE_SUCCESS;
     }
     return $this->returnSuccessMessage($output, $warnings->getAllMessages());
 }
Example #4
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $this->taskRunner->run($this->getCommittedFiles());
     } catch (ExceptionInterface $e) {
         // We'll fail hard on any exception not generated in GrumPHP
         $failed = $this->paths()->getAsciiContent('failed');
         if ($failed) {
             $output->writeln('<fg=red>' . $failed . '</fg=red>');
         }
         $output->writeln('<fg=red>' . $e->getMessage() . '</fg=red>');
         $output->writeln('<fg=yellow>To skip commit checks, add -n or --no-verify flag to commit command</fg=yellow>');
         return 1;
     }
     $succeeded = $this->paths()->getAsciiContent('succeeded');
     if ($succeeded) {
         $output->write('<fg=green>' . $succeeded . '</fg=green>');
     }
     return 0;
 }
Example #5
0
 function it_should_add_a_progress_listener_during_run(OutputInterface $output, TaskRunner $taskRunner, ContextInterface $context, EventDispatcherInterface $eventDispatcher)
 {
     $taskRunner->run($context)->shouldBeCalled();
     $eventDispatcher->addSubscriber(Argument::type('GrumPHP\\Event\\Subscriber\\ProgressSubscriber'))->shouldBeCalled();
     $this->run($output, $context)->shouldReturn(TaskRunnerHelper::CODE_SUCCESS);
 }
Example #6
0
 function it_should_add_a_progress_listener_during_run(OutputInterface $output, TaskRunner $taskRunner, ContextInterface $context, EventDispatcherInterface $eventDispatcher)
 {
     $taskRunner->run($context)->willReturn(new TaskResultCollection());
     $eventDispatcher->addSubscriber(Argument::type(ProgressSubscriber::class))->shouldBeCalled();
     $this->run($output, $context)->shouldReturn(TaskRunnerHelper::CODE_SUCCESS);
 }
Example #7
0
 function it_should_return_success_code_during_exceptions(OutputInterface $output, TaskRunner $taskRunner, ContextInterface $context)
 {
     $taskRunner->run($context)->shouldBeCalled();
     $this->run($output, $context)->shouldReturn(TaskRunnerHelper::CODE_SUCCESS);
 }