1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

[PR #7405/f7267c71 backport][stable-6] Fix the ability to run Composer "working_dir" dependent commands (#7459)

Fix the ability to run Composer "working_dir" dependent commands (#7405)

* pass the working_dir to all composer command invocations that are not global

* add changelog fragment

* Update changelog fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit f7267c7123)

Co-authored-by: Xavier Lacot <xavier@lacot.org>
This commit is contained in:
patchback[bot] 2023-11-01 08:22:38 +01:00 committed by GitHub
parent e7d86f5add
commit 46cbf60c2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- composer - fix impossible to run ``working_dir`` dependent commands. The module was throwing an error when trying to run a ``working_dir`` dependent command, because it tried to get the command help without passing the ``working_dir`` (https://github.com/ansible-collections/community.general/issues/3787).

View file

@ -170,10 +170,15 @@ def get_available_options(module, command='install'):
return command_help_json['definition']['options']
def composer_command(module, command, arguments="", options=None, global_command=False):
def composer_command(module, command, arguments="", options=None):
if options is None:
options = []
global_command = module.params['global_command']
if not global_command:
options.extend(['--working-dir', "'%s'" % module.params['working_dir']])
if module.params['executable'] is None:
php_path = module.get_bin_path("php", True, ["/usr/local/bin"])
else:
@ -217,7 +222,6 @@ def main():
module.fail_json(msg="Use the 'arguments' param for passing arguments with the 'command'")
arguments = module.params['arguments']
global_command = module.params['global_command']
available_options = get_available_options(module=module, command=command)
options = []
@ -234,9 +238,6 @@ def main():
option = "--%s" % option
options.append(option)
if not global_command:
options.extend(['--working-dir', "'%s'" % module.params['working_dir']])
option_params = {
'prefer_source': 'prefer-source',
'prefer_dist': 'prefer-dist',
@ -260,7 +261,7 @@ def main():
else:
module.exit_json(skipped=True, msg="command '%s' does not support check mode, skipping" % command)
rc, out, err = composer_command(module, command, arguments, options, global_command)
rc, out, err = composer_command(module, command, arguments, options)
if rc != 0:
output = parse_out(err)