1
0
Fork 0

Forward args/flags down to referenced events

pull/4616/head
Jordi Boggiano 2015-11-14 14:02:47 +00:00
parent 24ccaa328d
commit adc0bbeeb9
2 changed files with 7 additions and 3 deletions

View File

@ -201,8 +201,10 @@ simply running `composer test`:
> **Note:** Composer's bin-dir is pushed on top of the PATH so that binaries > **Note:** Composer's bin-dir is pushed on top of the PATH so that binaries
> of dependencies are easily accessible as CLI commands when writing scripts. > of dependencies are easily accessible as CLI commands when writing scripts.
Composer script can also called from other scripts, by prefixing the command name ## Referencing scripts
by `@`. For example the following syntax is valid:
To enable script re-use and avoid duplicates, you can call a script from another
one by prefixing the command name with `@`:
```json ```json
{ {

View File

@ -159,7 +159,9 @@ class EventDispatcher
$this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable)); $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable));
} }
$scriptName = substr($callable, 1); $scriptName = substr($callable, 1);
$return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode())); $args = $event->getArguments();
$flags = $event->getFlags();
$return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
} elseif ($this->isPhpScript($callable)) { } elseif ($this->isPhpScript($callable)) {
$className = substr($callable, 0, strpos($callable, '::')); $className = substr($callable, 0, strpos($callable, '::'));
$methodName = substr($callable, strpos($callable, '::') + 2); $methodName = substr($callable, strpos($callable, '::') + 2);