1
0
Fork 0

CAvoid calling PRE_COMMAND_RUN if no composer could be initialized

pull/7040/head
Jordi Boggiano 2018-01-24 15:36:00 +01:00
parent 352aefe48c
commit ccbbbccadb
1 changed files with 4 additions and 2 deletions

View File

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