From adc0bbeeb9e67dd00d38043a2d2950f94975fe41 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sat, 14 Nov 2015 14:02:47 +0000 Subject: [PATCH] Forward args/flags down to referenced events --- doc/articles/scripts.md | 6 ++++-- src/Composer/EventDispatcher/EventDispatcher.php | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index 92f9c5bdb..fcb2f7b4c 100644 --- a/doc/articles/scripts.md +++ b/doc/articles/scripts.md @@ -201,8 +201,10 @@ simply running `composer test`: > **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. -Composer script can also called from other scripts, by prefixing the command name -by `@`. For example the following syntax is valid: +## Referencing scripts + +To enable script re-use and avoid duplicates, you can call a script from another +one by prefixing the command name with `@`: ```json { diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index aadc96c91..c669b9dab 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -159,7 +159,9 @@ class EventDispatcher $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable)); } $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)) { $className = substr($callable, 0, strpos($callable, '::')); $methodName = substr($callable, strpos($callable, '::') + 2);