Explorar el Código

CAvoid calling PRE_COMMAND_RUN if no composer could be initialized

Jordi Boggiano hace 7 años
padre
commit
ccbbbccadb
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      src/Composer/Command/BaseCommand.php

+ 4 - 2
src/Composer/Command/BaseCommand.php

@@ -131,8 +131,10 @@ abstract class BaseCommand extends Command
         if (null === $composer) {
             $composer = Factory::createGlobal($this->getIO(), false);
         }
-        $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
-        $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
+        if ($composer) {
+            $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
+            $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
+        }
 
         if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
             $input->setOption('no-progress', true);