From 498cdad348ec33bc90de45f8c981a8121dfa3441 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 25 Mar 2015 14:53:52 +0100 Subject: [PATCH] Fix autoloads not being included. Closes #13. --- src/Composer/StudioPlugin.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Composer/StudioPlugin.php b/src/Composer/StudioPlugin.php index 602b891..55babdb 100644 --- a/src/Composer/StudioPlugin.php +++ b/src/Composer/StudioPlugin.php @@ -70,11 +70,18 @@ protected function autoloadFrom(array $directories) protected function appendIncludes(array $includes) { - $contents = "\n" . '// @generated by Composer Studio (https://github.com/franzliedke/studio)' . "\n"; - $contents .= "\n" . implode("\n", $includes) . "\n"; + $code = '// @generated by Composer Studio (https://github.com/franzliedke/studio)' . "\n"; + $code .= "\n" . implode("\n", $includes) . "\n"; $autoloadFile = 'vendor/autoload.php'; + $contents = file_get_contents($autoloadFile); - file_put_contents($autoloadFile, $contents, FILE_APPEND); + $contents = str_replace( + 'return ComposerAutoloader', + "$code\nreturn ComposerAutoloader", + $contents + ); + + file_put_contents($autoloadFile, $contents); } }