Merge pull request #94 from komuta/clean-composer-options
Unify composer options parsing
This commit is contained in:
commit
39cb571064
1 changed files with 21 additions and 17 deletions
|
@ -128,30 +128,34 @@ def main():
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
|
||||||
module.params["working_dir"] = os.path.abspath(module.params["working_dir"])
|
options = []
|
||||||
|
|
||||||
options = set([])
|
|
||||||
# Default options
|
# Default options
|
||||||
options.add("--no-ansi")
|
options.append('--no-ansi')
|
||||||
options.add("--no-progress")
|
options.append('--no-progress')
|
||||||
options.add("--no-interaction")
|
options.append('--no-interaction')
|
||||||
|
|
||||||
if module.check_mode:
|
options.extend(['--working-dir', os.path.abspath(module.params['working_dir'])])
|
||||||
options.add("--dry-run")
|
|
||||||
del module.params['CHECKMODE']
|
|
||||||
|
|
||||||
# Get composer command with fallback to default
|
# Get composer command with fallback to default
|
||||||
command = module.params['command']
|
command = module.params['command']
|
||||||
del module.params['command'];
|
|
||||||
|
|
||||||
# Prepare options
|
# Prepare options
|
||||||
for i in module.params:
|
if module.params['prefer_source']:
|
||||||
opt = "--%s" % i.replace("_","-")
|
options.append('--prefer-source')
|
||||||
p = module.params[i]
|
if module.params['prefer_dist']:
|
||||||
if isinstance(p, (bool)) and p:
|
options.append('--prefer-dist')
|
||||||
options.add(opt)
|
if module.params['no_dev']:
|
||||||
elif isinstance(p, (str)):
|
options.append('--no-dev')
|
||||||
options.add("%s=%s" % (opt, p))
|
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)
|
rc, out, err = composer_install(module, command, options)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue