npm: replace test with required_if (#6848)

* npm: replace test with required_if

* add changelog frag
This commit is contained in:
Alexei Znamensky 2023-07-06 08:07:58 +12:00 committed by GitHub
parent c34a22717e
commit 11406715f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 14 deletions

View file

@ -285,7 +285,8 @@ def main():
arg_spec['global'] = dict(default=False, type='bool')
module = AnsibleModule(
argument_spec=arg_spec,
supports_check_mode=True
required_if=[('state', 'absent', ['name'])],
supports_check_mode=True,
)
name = module.params['name']
@ -304,8 +305,6 @@ def main():
if not path and not glbl:
module.fail_json(msg='path must be specified when not using global')
if state == 'absent' and not name:
module.fail_json(msg='uninstalling a package is only available for named packages')
npm = Npm(module, name=name, path=path, version=version, glbl=glbl, production=production,
executable=executable, registry=registry, ignore_scripts=ignore_scripts,