npm: Validate all option types (#58965)

* Add type validation for name, version and registry
* Add changelog fragment
* Remove ignore of E337 and E338
pull/59174/head
Hannes Ljungberg 5 years ago committed by Abhijeet Kasurde
parent fbb4eaaba9
commit 6f94995b52

@ -0,0 +1,2 @@
bugfixes:
- "npm - Validate that all passed options have proper types."

@ -26,14 +26,17 @@ options:
name: name:
description: description:
- The name of a node.js library to install - The name of a node.js library to install
type: str
required: false required: false
path: path:
description: description:
- The base path where to install the node.js libraries - The base path where to install the node.js libraries
type: path
required: false required: false
version: version:
description: description:
- The version to be installed - The version to be installed
type: str
required: false required: false
global: global:
description: description:
@ -45,6 +48,7 @@ options:
description: description:
- The executable location for npm. - The executable location for npm.
- This is useful if you are using a version manager, such as nvm - This is useful if you are using a version manager, such as nvm
type: path
required: false required: false
ignore_scripts: ignore_scripts:
description: description:
@ -75,11 +79,13 @@ options:
description: description:
- The registry to install modules from. - The registry to install modules from.
required: false required: false
type: str
version_added: "1.6" version_added: "1.6"
state: state:
description: description:
- The state of the node.js library - The state of the node.js library
required: false required: false
type: str
default: present default: present
choices: [ "present", "absent", "latest" ] choices: [ "present", "absent", "latest" ]
requirements: requirements:
@ -241,12 +247,12 @@ class Npm(object):
def main(): def main():
arg_spec = dict( arg_spec = dict(
name=dict(default=None), name=dict(default=None, type='str'),
path=dict(default=None, type='path'), path=dict(default=None, type='path'),
version=dict(default=None), version=dict(default=None, type='str'),
production=dict(default='no', type='bool'), production=dict(default='no', type='bool'),
executable=dict(default=None, type='path'), executable=dict(default=None, type='path'),
registry=dict(default=None), registry=dict(default=None, type='str'),
state=dict(default='present', choices=['present', 'absent', 'latest']), state=dict(default='present', choices=['present', 'absent', 'latest']),
ignore_scripts=dict(default=False, type='bool'), ignore_scripts=dict(default=False, type='bool'),
unsafe_perm=dict(default=False, type='bool'), unsafe_perm=dict(default=False, type='bool'),

@ -3025,8 +3025,6 @@ lib/ansible/modules/packaging/language/gem.py E337
lib/ansible/modules/packaging/language/maven_artifact.py E324 lib/ansible/modules/packaging/language/maven_artifact.py E324
lib/ansible/modules/packaging/language/maven_artifact.py E337 lib/ansible/modules/packaging/language/maven_artifact.py E337
lib/ansible/modules/packaging/language/maven_artifact.py E338 lib/ansible/modules/packaging/language/maven_artifact.py E338
lib/ansible/modules/packaging/language/npm.py E337
lib/ansible/modules/packaging/language/npm.py E338
lib/ansible/modules/packaging/language/pear.py E322 lib/ansible/modules/packaging/language/pear.py E322
lib/ansible/modules/packaging/language/pear.py E326 lib/ansible/modules/packaging/language/pear.py E326
lib/ansible/modules/packaging/language/pear.py E337 lib/ansible/modules/packaging/language/pear.py E337

Loading…
Cancel
Save