Merge remote-tracking branch 'MaxGfeller/run-script-enhancement'
commit
33cedda708
|
@ -73,7 +73,11 @@ EOT
|
||||||
if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
|
if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
|
||||||
throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $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));
|
throw new \InvalidArgumentException(sprintf('Script "%s" does not exist', $script));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,6 +216,19 @@ class EventDispatcher
|
||||||
return call_user_func_array('array_merge', $listeners[$event->getName()]);
|
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
|
* Finds all listeners defined as scripts in the package
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue