add registry option to npm module
This commit is contained in:
parent
fee79e6501
commit
6b5aaf8e64
1 changed files with 14 additions and 1 deletions
|
@ -55,6 +55,10 @@ options:
|
||||||
- Install dependencies in production mode, excluding devDependencies
|
- Install dependencies in production mode, excluding devDependencies
|
||||||
required: false
|
required: false
|
||||||
default: no
|
default: no
|
||||||
|
registry:
|
||||||
|
description:
|
||||||
|
- The registry to install modules from.
|
||||||
|
required: false
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- The state of the node.js library
|
- The state of the node.js library
|
||||||
|
@ -76,6 +80,9 @@ description: Install "coffee-script" node.js package globally.
|
||||||
description: Remove the globally package "coffee-script".
|
description: Remove the globally package "coffee-script".
|
||||||
- npm: name=coffee-script global=yes state=absent
|
- npm: name=coffee-script global=yes state=absent
|
||||||
|
|
||||||
|
description: Install "coffee-script" node.js package from custom registry.
|
||||||
|
- npm: name=coffee-script registry=http://registry.mysite.com
|
||||||
|
|
||||||
description: Install packages based on package.json.
|
description: Install packages based on package.json.
|
||||||
- npm: path=/app/location
|
- npm: path=/app/location
|
||||||
|
|
||||||
|
@ -100,6 +107,7 @@ class Npm(object):
|
||||||
self.name = kwargs['name']
|
self.name = kwargs['name']
|
||||||
self.version = kwargs['version']
|
self.version = kwargs['version']
|
||||||
self.path = kwargs['path']
|
self.path = kwargs['path']
|
||||||
|
self.registry = kwargs['registry']
|
||||||
self.production = kwargs['production']
|
self.production = kwargs['production']
|
||||||
|
|
||||||
if kwargs['executable']:
|
if kwargs['executable']:
|
||||||
|
@ -122,6 +130,9 @@ class Npm(object):
|
||||||
cmd.append('--production')
|
cmd.append('--production')
|
||||||
if self.name:
|
if self.name:
|
||||||
cmd.append(self.name_version)
|
cmd.append(self.name_version)
|
||||||
|
if self.registry:
|
||||||
|
cmd.append('--registry')
|
||||||
|
cmd.append(self.registry)
|
||||||
|
|
||||||
#If path is specified, cd into that path and run the command.
|
#If path is specified, cd into that path and run the command.
|
||||||
if self.path:
|
if self.path:
|
||||||
|
@ -178,6 +189,7 @@ def main():
|
||||||
version=dict(default=None),
|
version=dict(default=None),
|
||||||
production=dict(default='no', type='bool'),
|
production=dict(default='no', type='bool'),
|
||||||
executable=dict(default=None),
|
executable=dict(default=None),
|
||||||
|
registry=dict(default=None),
|
||||||
state=dict(default='present', choices=['present', 'absent', 'latest'])
|
state=dict(default='present', choices=['present', 'absent', 'latest'])
|
||||||
)
|
)
|
||||||
arg_spec['global'] = dict(default='no', type='bool')
|
arg_spec['global'] = dict(default='no', type='bool')
|
||||||
|
@ -192,6 +204,7 @@ def main():
|
||||||
glbl = module.params['global']
|
glbl = module.params['global']
|
||||||
production = module.params['production']
|
production = module.params['production']
|
||||||
executable = module.params['executable']
|
executable = module.params['executable']
|
||||||
|
registry = module.params['registry']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
|
||||||
if not path and not glbl:
|
if not path and not glbl:
|
||||||
|
@ -200,7 +213,7 @@ def main():
|
||||||
module.fail_json(msg='uninstalling a package is only available for named packages')
|
module.fail_json(msg='uninstalling a package is only available for named packages')
|
||||||
|
|
||||||
npm = Npm(module, name=name, path=path, version=version, glbl=glbl, production=production, \
|
npm = Npm(module, name=name, path=path, version=version, glbl=glbl, production=production, \
|
||||||
executable=executable)
|
executable=executable, registry=registry)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if state == 'present':
|
if state == 'present':
|
||||||
|
|
Loading…
Reference in a new issue