mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Added npm ci command (#49665)
* #49664 Added npm ci command * Update lib/ansible/modules/packaging/language/npm.py Sure Co-Authored-By: Bramzor <bramverdonck@telenet.be> * Moved ci_install so it would work for specific packages Would this work? * Reverted last commit npm ci will remove node_modules so cannot be used it to install a specific module. * Update lib/ansible/modules/packaging/language/npm.py Co-Authored-By: Bramzor <bramverdonck@telenet.be> * Update lib/ansible/modules/packaging/language/npm.py Co-Authored-By: Bramzor <bramverdonck@telenet.be> * Update lib/ansible/modules/packaging/language/npm.py Co-Authored-By: Bramzor <bramverdonck@telenet.be>
This commit is contained in:
parent
7d5418e3d0
commit
17186bbde0
2 changed files with 18 additions and 1 deletions
3
changelogs/fragments/49664-npm-added-ci-param.yaml
Normal file
3
changelogs/fragments/49664-npm-added-ci-param.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
minor_changes:
|
||||
- "npm ci feature added which allows to install a project with a clean slate: https://docs.npmjs.com/cli/ci.html"
|
|
@ -59,6 +59,12 @@ options:
|
|||
type: bool
|
||||
default: no
|
||||
version_added: "2.8"
|
||||
ci:
|
||||
description:
|
||||
- Install packages based on package-lock file, same as running npm ci
|
||||
type: bool
|
||||
default: no
|
||||
version_added: "2.8"
|
||||
production:
|
||||
description:
|
||||
- Install dependencies in production mode, excluding devDependencies
|
||||
|
@ -211,6 +217,9 @@ class Npm(object):
|
|||
def install(self):
|
||||
return self._exec(['install'])
|
||||
|
||||
def ci_install(self):
|
||||
return self._exec(['ci'])
|
||||
|
||||
def update(self):
|
||||
return self._exec(['update'])
|
||||
|
||||
|
@ -241,6 +250,7 @@ def main():
|
|||
state=dict(default='present', choices=['present', 'absent', 'latest']),
|
||||
ignore_scripts=dict(default=False, type='bool'),
|
||||
unsafe_perm=dict(default=False, type='bool'),
|
||||
ci=dict(default=False, type='bool'),
|
||||
)
|
||||
arg_spec['global'] = dict(default='no', type='bool')
|
||||
module = AnsibleModule(
|
||||
|
@ -258,6 +268,7 @@ def main():
|
|||
state = module.params['state']
|
||||
ignore_scripts = module.params['ignore_scripts']
|
||||
unsafe_perm = module.params['unsafe_perm']
|
||||
ci = module.params['ci']
|
||||
|
||||
if not path and not glbl:
|
||||
module.fail_json(msg='path must be specified when not using global')
|
||||
|
@ -269,7 +280,10 @@ def main():
|
|||
unsafe_perm=unsafe_perm, state=state)
|
||||
|
||||
changed = False
|
||||
if state == 'present':
|
||||
if ci:
|
||||
npm.ci_install()
|
||||
changed = True
|
||||
elif state == 'present':
|
||||
installed, missing = npm.list()
|
||||
if missing:
|
||||
changed = True
|
||||
|
|
Loading…
Reference in a new issue