diff --git a/src/Script/Composer/Composer.php b/src/Script/Composer/Composer.php index f12f93f8d2..cc1b3772f8 100644 --- a/src/Script/Composer/Composer.php +++ b/src/Script/Composer/Composer.php @@ -6,11 +6,23 @@ class Composer { - public static function removeUnusedServices( - Event $event, - Filesystem $filesystem = null - ) + + public static function removeUnusedServicesInDevOnly(Event $event, Filesystem $filesystem = null) { + self::removeUnusedServicesByExtraConfig($event, $filesystem, true); + } + + public static function removeUnusedServices(Event $event, Filesystem $filesystem = null) + { + self::removeUnusedServicesByExtraConfig($event, $filesystem, false); + } + + private static function removeUnusedServicesByExtraConfig(Event $event, Filesystem $filesystem = null, $onlyRunInDev = false) + { + if ($onlyRunInDev && !$event->isDevMode()){ + return; + } + $composer = $event->getComposer(); $extra = $composer->getPackage()->getExtra(); $listedServices = isset($extra['aws/aws-sdk-php']) diff --git a/src/Script/Composer/README.md b/src/Script/Composer/README.md index 742f7e01d4..714b57674f 100644 --- a/src/Script/Composer/README.md +++ b/src/Script/Composer/README.md @@ -5,7 +5,7 @@ you have feedback on the implementation, please visit the [open discussion](http we have on the topic. To avoid shipping unused services, specify which services you would like to keep in your `composer.json` file and -use the `Aws\\Script\\Composer::removeUnusedServices` script: +use the `Aws\\Script\\Composer::removeUnusedServices` or `Aws\\Script\\Composer::removeUnusedServicesInDevOnly` script: ``` {