From 89b0cb5e60516d84024fba5592cec0ba6352de70 Mon Sep 17 00:00:00 2001 From: "Joel (home)" Date: Sat, 3 Aug 2013 19:03:39 -1000 Subject: [PATCH] Fixed issue with non-components using "component" flag in json When non-component files use a "component" flag (see cartalyst/sentry as an example), the component-installer script would start throwing errors like this: > Script ComponentInstaller\Installer::postAutoloadDump handling the post-autoload-dump event terminated with an exception > [ErrorException] > Argument 2 passed to ComponentInstaller\Process\RequireJsProcess::aggregateScripts() must be an array, string given, called in /vendor/robloach/component-installer/src/ComponentInstaller/Process/RequireJsProcess.php on line 109 and defined This fix removes everything it can identify as a non-component from the list of packages. --- src/ComponentInstaller/Process/Process.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ComponentInstaller/Process/Process.php b/src/ComponentInstaller/Process/Process.php index ab65388..44a3a35 100644 --- a/src/ComponentInstaller/Process/Process.php +++ b/src/ComponentInstaller/Process/Process.php @@ -62,14 +62,24 @@ public function init() } // Get the available packages. + $allPackages = array(); $locker = $this->composer->getLocker(); if (isset($locker)) { $lockData = $locker->getLockData(); - $this->packages = isset($lockData['packages']) ? $lockData['packages'] : array(); + $allPackages = isset($lockData['packages']) ? $lockData['packages'] : array(); // Also merge in any of the development packages. $dev = isset($lockData['packages-dev']) ? $lockData['packages-dev'] : array(); foreach ($dev as $package) { + $allPackages[] = $package; + } + } + + // Only add those packages that we can reasonably + // assume are components into our packages list + foreach ($allPackages as $package) { + $extra = isset($package['extra']) ? $package['extra'] : array(); + if (isset($extra['component']) && is_array($extra['component'])) { $this->packages[] = $package; } }