From 4740a77de5405dbeb6cb7663fa8fa61b2577558d Mon Sep 17 00:00:00 2001 From: Netkas Date: Tue, 7 Feb 2023 16:23:20 -0500 Subject: [PATCH] Added pass-through arguments to `composer` command, all arguments beginning with `--composer-` will be passed to the `composer` command, for example `--composer-dev` will be passed as `--dev` to the `composer` command --- CHANGELOG.md | 2 ++ .../ComposerSourceBuiltin.php | 24 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd376f2..ff4dd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added file downloads progress +- Added pass-through arguments to `composer` command, all arguments beginning with `--composer-` will be passed to the + `composer` command, for example `--composer-dev` will be passed as `--dev` to the `composer` command ### Fixed diff --git a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php index 9c9361f..a18c896 100644 --- a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php +++ b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php @@ -373,11 +373,31 @@ namespace ncc\Classes\ComposerExtension; */ private static function getOptions(): array { + $results = []; + $arguments = Main::getArgs(); + + // Anything beginning with --composer- is a composer option + foreach ($arguments as $argument => $value) + { + if (str_starts_with($argument, 'composer-') && !in_array($argument, $results)) + { + if(is_bool($value) && $value) + { + $results[] = '--' . str_ireplace('composer-', '', $argument); + + } + else + { + $results[] = '--' . str_ireplace('composer-', '', $argument) . '=' . $value; + } + } + } + + $options = Functions::getConfigurationProperty('composer.options'); if ($options == null || !is_array($options)) - return []; + return $results; - $results = []; if (isset($options['quiet']) && $options['quiet']) $results[] = '--quiet'; if (isset($options['no_asni']) && $options['no_asni'])