fix npm installed command

This commit is contained in:
Aleksey Zhukov 2014-02-02 03:48:16 +04:00
parent e254cbc764
commit ca2b378ed5
2 changed files with 12 additions and 9 deletions

View File

@ -98,15 +98,18 @@ def install(pkg=None,
lines = npm_output.splitlines()
log.error(lines)
# Strip all lines until JSON output starts
while not lines[0].startswith('{') and not lines[0].startswith('['):
lines = lines[1:]
while lines:
# Strip all lines until JSON output starts
while not lines[0].startswith('{') and not lines[0].startswith('['):
lines = lines[1:]
try:
return json.loads(''.join(lines))
except ValueError:
# Still no JSON!! Return the stdout as a string
return npm_output
try:
return json.loads(''.join(lines))
except ValueError:
lines = lines[1:]
# Still no JSON!! Return the stdout as a string
return npm_output
def uninstall(pkg,

View File

@ -129,7 +129,7 @@ def installed(name,
ret['comment'] = 'Error installing \'{0}\': {1}'.format(name, err)
return ret
if call or isinstance(call, list) or isinstance(call, dict):
if call and (isinstance(call, list) or isinstance(call, dict)):
ret['result'] = True
version = call[0]['version']
pkg_name = call[0]['name']