Make npm.uninstall and npm.removed more consistent, Fix #4674

This commit is contained in:
Colton Myers 2013-05-15 14:51:43 -06:00
parent 3929ab64a5
commit 81a7d2d279
2 changed files with 16 additions and 9 deletions

View File

@ -10,6 +10,8 @@ import salt.utils
from salt.exceptions import CommandExecutionError
log = logging.getLogger(__name__)
def __virtual__():
'''
@ -121,7 +123,8 @@ def uninstall(pkg,
'''
if not _valid_version():
return '"{0}" is not available.'.format('npm.uninstall')
log.error('"{0}" is not available.'.format('npm.uninstall'))
return False
cmd = 'npm uninstall'
@ -133,7 +136,9 @@ def uninstall(pkg,
result = __salt__['cmd.run_all'](cmd, cwd=dir, runas=runas)
if result['retcode'] != 0:
raise CommandExecutionError(result['stderr'])
log.error(results['stderr'])
return False
return True
def list(pkg=None,

View File

@ -104,13 +104,15 @@ def removed(name,
ret['comment'] = 'Package {0} is set to be removed'.format(name)
return ret
call = __salt__["npm.uninstall"](pkg=name,
dir=dir,
runas=runas)
ret["result"] = True
ret["changes"][name] = "Removed"
ret["comment"] = "Package was successfully removed."
if __salt__["npm.uninstall"](pkg=name,
dir=dir,
runas=runas):
ret["result"] = True
ret["changes"][name] = 'Removed'
ret["comment"] = 'Package was successfully removed.'
else:
ret["result"] = False
ret["comment"] = 'Error removing package.'
return ret