mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[PR #6138/3d67f518 backport][stable-6] Fix Yarn global not working without explicit executable path (#6141)
Fix Yarn global not working without explicit executable path (#6138)
* Fix Yarn global not working without explicit executable path
* changelog fragment
* fix formatting and add test
* oops
(cherry picked from commit 3d67f51824
)
Co-authored-by: Sargun Vohra <sargun.vohra@gmail.com>
This commit is contained in:
parent
8c1b7e3ddb
commit
8efbd8172c
3 changed files with 18 additions and 7 deletions
2
changelogs/fragments/6138-fix-yarn-global.yml
Normal file
2
changelogs/fragments/6138-fix-yarn-global.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- yarn - fix ``global=true`` to not fail when `executable` wasn't specified (https://github.com/ansible-collections/community.general/pull/6132)
|
|
@ -179,15 +179,11 @@ class Yarn(object):
|
|||
self.registry = kwargs['registry']
|
||||
self.production = kwargs['production']
|
||||
self.ignore_scripts = kwargs['ignore_scripts']
|
||||
self.executable = kwargs['executable']
|
||||
|
||||
# Specify a version of package if version arg passed in
|
||||
self.name_version = None
|
||||
|
||||
if kwargs['executable']:
|
||||
self.executable = kwargs['executable'].split(' ')
|
||||
else:
|
||||
self.executable = [module.get_bin_path('yarn', True)]
|
||||
|
||||
if kwargs['version'] and self.name is not None:
|
||||
self.name_version = self.name + '@' + str(self.version)
|
||||
elif self.name is not None:
|
||||
|
@ -328,7 +324,6 @@ def main():
|
|||
version = module.params['version']
|
||||
globally = module.params['global']
|
||||
production = module.params['production']
|
||||
executable = module.params['executable']
|
||||
registry = module.params['registry']
|
||||
state = module.params['state']
|
||||
ignore_scripts = module.params['ignore_scripts']
|
||||
|
@ -345,9 +340,14 @@ def main():
|
|||
if state == 'latest':
|
||||
version = 'latest'
|
||||
|
||||
if module.params['executable']:
|
||||
executable = module.params['executable'].split(' ')
|
||||
else:
|
||||
executable = [module.get_bin_path('yarn', True)]
|
||||
|
||||
# When installing globally, use the defined path for global node_modules
|
||||
if globally:
|
||||
_rc, out, _err = module.run_command([executable, 'global', 'dir'], check_rc=True)
|
||||
_rc, out, _err = module.run_command(executable + ['global', 'dir'], check_rc=True)
|
||||
path = out.strip()
|
||||
|
||||
yarn = Yarn(module,
|
||||
|
|
|
@ -108,6 +108,15 @@
|
|||
that:
|
||||
- yarn_install_old_package is changed
|
||||
|
||||
- name: 'Again but without explicit executable path'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
name: left-pad
|
||||
version: 1.1.0
|
||||
state: present
|
||||
environment:
|
||||
PATH: '{{ yarn_bin_path }}:{{ node_bin_path }}:{{ ansible_env.PATH }}'
|
||||
|
||||
- name: 'Upgrade old package'
|
||||
yarn:
|
||||
path: '{{ remote_tmp_dir }}'
|
||||
|
|
Loading…
Reference in a new issue