mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
npm: add support for production
flag when using ci
(#4299)
* npm - add '--production` support to 'npm ci' flag * add changelog fragement for 4299 * Add backticks Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
56e8bf130a
commit
43af053d73
3 changed files with 75 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- npm - add ability to use ``production`` flag when ``ci`` is set (https://github.com/ansible-collections/community.general/pull/4299).
|
|
@ -175,7 +175,7 @@ class Npm(object):
|
|||
|
||||
if self.glbl:
|
||||
cmd.append('--global')
|
||||
if self.production and ('install' in cmd or 'update' in cmd):
|
||||
if self.production and ('install' in cmd or 'update' in cmd or 'ci' in cmd):
|
||||
cmd.append('--production')
|
||||
if self.ignore_scripts:
|
||||
cmd.append('--ignore-scripts')
|
||||
|
|
|
@ -188,3 +188,75 @@ class NPMModuleTestCase(ModuleTestCase):
|
|||
call(['/testbin/npm', 'list', '--json', '--long', '--global'], check_rc=False, cwd=None),
|
||||
call(['/testbin/npm', 'uninstall', '--global', 'coffee-script'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_package_json(self):
|
||||
set_module_args({
|
||||
'global': 'true',
|
||||
'state': 'present'
|
||||
})
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{}', ''),
|
||||
(0, '{}', ''),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/npm', 'install', '--global'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_package_json_production(self):
|
||||
set_module_args({
|
||||
'production': 'true',
|
||||
'global': 'true',
|
||||
'state': 'present',
|
||||
})
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{}', ''),
|
||||
(0, '{}', ''),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/npm', 'install', '--global', '--production'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_package_json_ci(self):
|
||||
set_module_args({
|
||||
'ci': 'true',
|
||||
'global': 'true',
|
||||
'state': 'present'
|
||||
})
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{}', ''),
|
||||
(0, '{}', ''),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/npm', 'ci', '--global'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
||||
def test_present_package_json_ci_production(self):
|
||||
set_module_args({
|
||||
'ci': 'true',
|
||||
'production': 'true',
|
||||
'global': 'true',
|
||||
'state': 'present'
|
||||
})
|
||||
self.module_main_command.side_effect = [
|
||||
(0, '{}', ''),
|
||||
(0, '{}', ''),
|
||||
]
|
||||
|
||||
result = self.module_main(AnsibleExitJson)
|
||||
|
||||
self.assertTrue(result['changed'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call(['/testbin/npm', 'ci', '--global', '--production'], check_rc=True, cwd=None),
|
||||
])
|
||||
|
|
Loading…
Reference in a new issue