From 74d5591af789f542aa6375ad4b996408fc8e5505 Mon Sep 17 00:00:00 2001 From: Fabian Kochem Date: Mon, 14 Apr 2014 22:48:05 +0200 Subject: [PATCH] new parameter: 'registry' for NPM module --- salt/modules/npm.py | 9 ++++++++- salt/states/npm.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/salt/modules/npm.py b/salt/modules/npm.py index 2be378d35b..6912e46344 100644 --- a/salt/modules/npm.py +++ b/salt/modules/npm.py @@ -43,7 +43,8 @@ def _valid_version(): def install(pkg=None, dir=None, - runas=None): + runas=None, + registry=None): ''' Install an NPM package. @@ -62,6 +63,9 @@ def install(pkg=None, runas The user to run NPM with + registry + The NPM registry to install the package from. + CLI Example: .. code-block:: bash @@ -79,6 +83,9 @@ def install(pkg=None, if dir is None: cmd += ' --global' + if registry: + cmd += ' --registry="{0}"'.format(registry) + if pkg: cmd += ' "{0}"'.format(pkg) diff --git a/salt/states/npm.py b/salt/states/npm.py index ab74eea436..e99c08cbdc 100644 --- a/salt/states/npm.py +++ b/salt/states/npm.py @@ -35,7 +35,8 @@ def installed(name, dir=None, runas=None, user=None, - force_reinstall=False): + force_reinstall=False, + registry=None): ''' Verify that the given package is installed and is at the correct version (if specified). @@ -63,6 +64,9 @@ def installed(name, user The user to run NPM with + registry + The NPM registry to install the package from. + .. versionadded:: 0.17.0 force_reinstall @@ -97,7 +101,9 @@ def installed(name, prefix = name.split('@')[0].strip() try: - installed_pkgs = __salt__['npm.list'](pkg=name, dir=dir) + installed_pkgs = __salt__['npm.list'](pkg=name, + dir=dir, + registry=registry) except (CommandNotFoundError, CommandExecutionError) as err: ret['result'] = False ret['comment'] = 'Error installing \'{0}\': {1}'.format(name, err)