diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 052c17213..9e8aacb7d 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -131,7 +131,7 @@ abstract class BaseCommand extends Command if (null === $composer) { $composer = Factory::createGlobal($this->getIO(), false); } - $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input); + $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')) { diff --git a/src/Composer/Plugin/PreCommandRunEvent.php b/src/Composer/Plugin/PreCommandRunEvent.php index ab2b035a1..60ad05b4a 100644 --- a/src/Composer/Plugin/PreCommandRunEvent.php +++ b/src/Composer/Plugin/PreCommandRunEvent.php @@ -27,16 +27,23 @@ class PreCommandRunEvent extends Event */ private $input; + /** + * @var string + */ + private $command; + /** * Constructor. * - * @param string $name The event name + * @param string $name The event name * @param InputInterface $input + * @param string $command The command about to be executed */ - public function __construct($name, InputInterface $input) + public function __construct($name, InputInterface $input, $command) { parent::__construct($name); $this->input = $input; + $this->command = $command; } /** @@ -48,4 +55,14 @@ class PreCommandRunEvent extends Event { return $this->input; } + + /** + * Returns the command about to be executed + * + * @return string + */ + public function getCommand() + { + return $this->command; + } }