浏览代码

Forward args/flags down to referenced events

Jordi Boggiano 9 年之前
父节点
当前提交
adc0bbeeb9
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 4 2
      doc/articles/scripts.md
  2. 3 1
      src/Composer/EventDispatcher/EventDispatcher.php

+ 4 - 2
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
 {

+ 3 - 1
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);