npm: Add force flag (#8885)
* Add force flag for nmp module * Add CHANGELOG fragment * Add force to cmdrunner * Update CHANGELOG * Add commapull/8895/head
parent
ac302eb77d
commit
38479ee9ff
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- npm - add ``force`` parameter to allow ``--force`` (https://github.com/ansible-collections/community.general/pull/8885).
|
|
@ -96,6 +96,12 @@ options:
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
version_added: 2.5.0
|
version_added: 2.5.0
|
||||||
|
force:
|
||||||
|
description:
|
||||||
|
- Use the C(--force) flag when installing.
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: 9.5.0
|
||||||
requirements:
|
requirements:
|
||||||
- npm installed in bin path (recommended /usr/local/bin)
|
- npm installed in bin path (recommended /usr/local/bin)
|
||||||
'''
|
'''
|
||||||
|
@ -117,6 +123,11 @@ EXAMPLES = r'''
|
||||||
name: coffee-script
|
name: coffee-script
|
||||||
global: true
|
global: true
|
||||||
|
|
||||||
|
- name: Force Install "coffee-script" node.js package.
|
||||||
|
community.general.npm:
|
||||||
|
name: coffee-script
|
||||||
|
force: true
|
||||||
|
|
||||||
- name: Remove the globally package "coffee-script".
|
- name: Remove the globally package "coffee-script".
|
||||||
community.general.npm:
|
community.general.npm:
|
||||||
name: coffee-script
|
name: coffee-script
|
||||||
|
@ -167,6 +178,7 @@ class Npm(object):
|
||||||
self.state = kwargs['state']
|
self.state = kwargs['state']
|
||||||
self.no_optional = kwargs['no_optional']
|
self.no_optional = kwargs['no_optional']
|
||||||
self.no_bin_links = kwargs['no_bin_links']
|
self.no_bin_links = kwargs['no_bin_links']
|
||||||
|
self.force = kwargs['force']
|
||||||
|
|
||||||
if kwargs['executable']:
|
if kwargs['executable']:
|
||||||
self.executable = kwargs['executable'].split(' ')
|
self.executable = kwargs['executable'].split(' ')
|
||||||
|
@ -191,6 +203,7 @@ class Npm(object):
|
||||||
registry=cmd_runner_fmt.as_opt_val('--registry'),
|
registry=cmd_runner_fmt.as_opt_val('--registry'),
|
||||||
no_optional=cmd_runner_fmt.as_bool('--no-optional'),
|
no_optional=cmd_runner_fmt.as_bool('--no-optional'),
|
||||||
no_bin_links=cmd_runner_fmt.as_bool('--no-bin-links'),
|
no_bin_links=cmd_runner_fmt.as_bool('--no-bin-links'),
|
||||||
|
force=cmd_runner_fmt.as_bool('--force'),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -212,7 +225,7 @@ class Npm(object):
|
||||||
params['name_version'] = self.name_version if add_package_name else None
|
params['name_version'] = self.name_version if add_package_name else None
|
||||||
|
|
||||||
with self.runner(
|
with self.runner(
|
||||||
"exec_args global_ production ignore_scripts unsafe_perm name_version registry no_optional no_bin_links",
|
"exec_args global_ production ignore_scripts unsafe_perm name_version registry no_optional no_bin_links force",
|
||||||
check_rc=check_rc, cwd=cwd
|
check_rc=check_rc, cwd=cwd
|
||||||
) as ctx:
|
) as ctx:
|
||||||
rc, out, err = ctx.run(**params)
|
rc, out, err = ctx.run(**params)
|
||||||
|
@ -289,6 +302,7 @@ def main():
|
||||||
ci=dict(default=False, type='bool'),
|
ci=dict(default=False, type='bool'),
|
||||||
no_optional=dict(default=False, type='bool'),
|
no_optional=dict(default=False, type='bool'),
|
||||||
no_bin_links=dict(default=False, type='bool'),
|
no_bin_links=dict(default=False, type='bool'),
|
||||||
|
force=dict(default=False, type='bool'),
|
||||||
)
|
)
|
||||||
arg_spec['global'] = dict(default=False, type='bool')
|
arg_spec['global'] = dict(default=False, type='bool')
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
@ -318,7 +332,8 @@ def main():
|
||||||
unsafe_perm=module.params['unsafe_perm'],
|
unsafe_perm=module.params['unsafe_perm'],
|
||||||
state=state,
|
state=state,
|
||||||
no_optional=module.params['no_optional'],
|
no_optional=module.params['no_optional'],
|
||||||
no_bin_links=module.params['no_bin_links'])
|
no_bin_links=module.params['no_bin_links'],
|
||||||
|
force=module.params['force'])
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if module.params['ci']:
|
if module.params['ci']:
|
||||||
|
|
Loading…
Reference in New Issue