diff --git a/src/Composer/Script/EventDispatcher.php b/src/Composer/Script/EventDispatcher.php
index c876e8920..c0fefb99e 100644
--- a/src/Composer/Script/EventDispatcher.php
+++ b/src/Composer/Script/EventDispatcher.php
@@ -120,8 +120,10 @@ class EventDispatcher
throw $e;
}
} else {
- if (0 !== $this->process->execute($callable)) {
- $event->getIO()->write(sprintf('Script %s handling the %s event returned with an error: %s', $callable, $event->getName(), $this->process->getErrorOutput()));
+ if (0 !== ($exitCode = $this->process->execute($callable))) {
+ $event->getIO()->write(sprintf('Script %s handling the %s event returned with an error', $callable, $event->getName()));
+
+ throw new \RuntimeException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
}
}
}
diff --git a/tests/Composer/Test/Script/EventDispatcherTest.php b/tests/Composer/Test/Script/EventDispatcherTest.php
index 866d111b8..cd8f8e76f 100644
--- a/tests/Composer/Test/Script/EventDispatcherTest.php
+++ b/tests/Composer/Test/Script/EventDispatcherTest.php
@@ -59,7 +59,8 @@ class EventDispatcherTest extends TestCase
$process->expects($this->once())
->method('execute')
- ->with($command);
+ ->with($command)
+ ->will($this->returnValue(0));
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
}
@@ -80,7 +81,8 @@ class EventDispatcherTest extends TestCase
->getMock();
$process->expects($this->exactly(2))
- ->method('execute');
+ ->method('execute')
+ ->will($this->returnValue(0));
$listeners = array(
'echo -n foo',
@@ -165,8 +167,9 @@ class EventDispatcherTest extends TestCase
$io->expects($this->once())
->method('write')
- ->with($this->equalTo('Script '.$code.' handling the post-install-cmd event returned with an error: '));
+ ->with($this->equalTo('Script '.$code.' handling the post-install-cmd event returned with an error'));
+ $this->setExpectedException('RuntimeException');
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
}