mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
Make npm.uninstall and npm.removed more consistent, Fix #4674
This commit is contained in:
parent
3929ab64a5
commit
81a7d2d279
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user