def package_version(package, local=False, npm='npm'):
 options = ['--json true', '--silent']
 if local:
  options.append('-l')
 else:
  options.append('-g')
 options = ' '.join(options)
 with hide('running', 'stdout'):
  res = run(('%(npm)s list %(options)s' % locals()), pty=False)
 dependencies = json.loads(res).get('dependencies', {})
 pkg_data = dependencies.get(package)
 if pkg_data:
  return pkg_data['version']
 else:
  return None

def package_version ( package , local = False , npm = 'npm' ) : options = [ '--json true' , '--silent' ] if local : options . append ( '-l' ) else : options . append ( '-g' ) options = ' ' . join ( options ) with hide ( 'running' , 'stdout' ) : res = run ( ( '%(npm)s list %(options)s' % locals ( ) ) , pty = False ) dependencies = json . loads ( res ) . get ( 'dependencies' , { } ) pkg_data = dependencies . get ( package ) if pkg_data : return pkg_data [ 'version' ] else : return None
get the installed version of a node .