diff --git a/changelogs/fragments/474-yarn_fix-outdated-fix-list.yml b/changelogs/fragments/474-yarn_fix-outdated-fix-list.yml new file mode 100644 index 0000000000..baa19b7070 --- /dev/null +++ b/changelogs/fragments/474-yarn_fix-outdated-fix-list.yml @@ -0,0 +1,3 @@ +bugfixes: + - yarn - fixed an index out of range error when no outdated packages where returned by yarn executable (see https://github.com/ansible-collections/community.general/pull/474). + - yarn - fixed an too many values to unpack error when scoped packages are installed (see https://github.com/ansible-collections/community.general/pull/474). diff --git a/plugins/modules/packaging/language/yarn.py b/plugins/modules/packaging/language/yarn.py index 8b21753851..7def1698f0 100644 --- a/plugins/modules/packaging/language/yarn.py +++ b/plugins/modules/packaging/language/yarn.py @@ -243,7 +243,7 @@ class Yarn(object): return installed, missing for dep in dependencies: - name, version = dep['name'].split('@') + name, version = dep['name'].rsplit('@', 1) installed.append(name) if self.name not in installed: @@ -274,6 +274,9 @@ class Yarn(object): if err: self.module.fail_json(msg=err) + if not cmd_result: + return outdated + outdated_packages_data = cmd_result.splitlines()[1] data = json.loads(outdated_packages_data) diff --git a/tests/integration/targets/yarn/templates/package.j2 b/tests/integration/targets/yarn/templates/package.j2 index 5af8b4bab6..8ca73aa83a 100644 --- a/tests/integration/targets/yarn/templates/package.j2 +++ b/tests/integration/targets/yarn/templates/package.j2 @@ -3,6 +3,7 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "iconv-lite": "^0.4.21" + "iconv-lite": "^0.4.21", + "@types/node": "^12.0.0" } } \ No newline at end of file