1
0
Fork 0

Merge remote-tracking branch 'MaxGfeller/run-script-enhancement'

pull/3142/head
Jordi Boggiano 2014-07-20 19:07:45 +02:00
commit 33cedda708
2 changed files with 17 additions and 0 deletions

View File

@ -73,7 +73,11 @@ EOT
if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
}
}
$hasListeners = $this->getComposer()->getEventDispatcher()->hasEventListeners(new \Composer\Script\CommandEvent($script, $this->getComposer(), $this->getIO()));
if(!$hasListeners) {
throw new \InvalidArgumentException(sprintf('Script "%s" does not exist', $script));
}

View File

@ -216,6 +216,19 @@ class EventDispatcher
return call_user_func_array('array_merge', $listeners[$event->getName()]);
}
/**
* Checks if an event has listeners registered
*
* @param Event $event
* @return boolean
*/
public function hasEventListeners(Event $event)
{
$listeners = $this->getListeners($event);
return (sizeof($listeners) > 0);
}
/**
* Finds all listeners defined as scripts in the package
*