From e1008059ecf9ac94902501b5942f5fd07278286b Mon Sep 17 00:00:00 2001 From: Julien Pepy Date: Mon, 18 Aug 2014 09:28:32 +0200 Subject: [PATCH] Clean options building in Composer module --- packaging/language/composer.py | 38 +++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/packaging/language/composer.py b/packaging/language/composer.py index f788f53dd5c..86863909be8 100644 --- a/packaging/language/composer.py +++ b/packaging/language/composer.py @@ -128,30 +128,34 @@ def main(): supports_check_mode=True ) - module.params["working_dir"] = os.path.abspath(module.params["working_dir"]) + options = [] - options = set([]) # Default options - options.add("--no-ansi") - options.add("--no-progress") - options.add("--no-interaction") + options.append('--no-ansi') + options.append('--no-progress') + options.append('--no-interaction') - if module.check_mode: - options.add("--dry-run") - del module.params['CHECKMODE'] + options.extend(['--working-dir', os.path.abspath(module.params['working_dir'])]) - # Get composer command with fallback to default + # Get composer command with fallback to default command = module.params['command'] - del module.params['command']; # Prepare options - for i in module.params: - opt = "--%s" % i.replace("_","-") - p = module.params[i] - if isinstance(p, (bool)) and p: - options.add(opt) - elif isinstance(p, (str)): - options.add("%s=%s" % (opt, p)) + if module.params['prefer_source']: + options.append('--prefer-source') + if module.params['prefer_dist']: + options.append('--prefer-dist') + if module.params['no_dev']: + options.append('--no-dev') + if module.params['no_scripts']: + options.append('--no-scripts') + if module.params['no_plugins']: + options.append('--no-plugins') + if module.params['optimize_autoloader']: + options.append('--optimize-autoloader') + + if module.check_mode: + options.append('--dry-run') rc, out, err = composer_install(module, command, options)