mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add no-optional flag to npm (#1428)
* Add no-optional flag to npm * Add changelog * Oops * Add no_optional to Npm class
This commit is contained in:
parent
ae0d3cb090
commit
dc60e71fd5
2 changed files with 15 additions and 1 deletions
3
changelogs/fragments/1428-npm-no-optional.yml
Normal file
3
changelogs/fragments/1428-npm-no-optional.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
minor_changes:
|
||||
- npm - add ``no-optional`` option (https://github.com/ansible-collections/community.general/issues/1421).
|
|
@ -76,6 +76,12 @@ options:
|
|||
type: str
|
||||
default: present
|
||||
choices: [ "present", "absent", "latest" ]
|
||||
no_optional:
|
||||
description:
|
||||
- Use the C(--no-optional) flag when installing.
|
||||
type: bool
|
||||
default: no
|
||||
version_added: 2.0.0
|
||||
requirements:
|
||||
- npm installed in bin path (recommended /usr/local/bin)
|
||||
'''
|
||||
|
@ -144,6 +150,7 @@ class Npm(object):
|
|||
self.ignore_scripts = kwargs['ignore_scripts']
|
||||
self.unsafe_perm = kwargs['unsafe_perm']
|
||||
self.state = kwargs['state']
|
||||
self.no_optional = kwargs['no_optional']
|
||||
|
||||
if kwargs['executable']:
|
||||
self.executable = kwargs['executable'].split(' ')
|
||||
|
@ -172,6 +179,8 @@ class Npm(object):
|
|||
if self.registry:
|
||||
cmd.append('--registry')
|
||||
cmd.append(self.registry)
|
||||
if self.no_optional:
|
||||
cmd.append('--no-optional')
|
||||
|
||||
# If path is specified, cd into that path and run the command.
|
||||
cwd = None
|
||||
|
@ -245,6 +254,7 @@ def main():
|
|||
ignore_scripts=dict(default=False, type='bool'),
|
||||
unsafe_perm=dict(default=False, type='bool'),
|
||||
ci=dict(default=False, type='bool'),
|
||||
no_optional=dict(default=False, type='bool'),
|
||||
)
|
||||
arg_spec['global'] = dict(default=False, type='bool')
|
||||
module = AnsibleModule(
|
||||
|
@ -263,6 +273,7 @@ def main():
|
|||
ignore_scripts = module.params['ignore_scripts']
|
||||
unsafe_perm = module.params['unsafe_perm']
|
||||
ci = module.params['ci']
|
||||
no_optional = module.params['no_optional']
|
||||
|
||||
if not path and not glbl:
|
||||
module.fail_json(msg='path must be specified when not using global')
|
||||
|
@ -271,7 +282,7 @@ def main():
|
|||
|
||||
npm = Npm(module, name=name, path=path, version=version, glbl=glbl, production=production,
|
||||
executable=executable, registry=registry, ignore_scripts=ignore_scripts,
|
||||
unsafe_perm=unsafe_perm, state=state)
|
||||
unsafe_perm=unsafe_perm, state=state, no_optional=no_optional)
|
||||
|
||||
changed = False
|
||||
if ci:
|
||||
|
|
Loading…
Reference in a new issue