ó
HVc           @   s7   d  Z  d d l Z d d l Z d   Z d d  Z d S(   s6   Utility to use the Uglify JS Compiler CLI from Python.i˙˙˙˙Nc           C   s   t  j d d g  d S(   s2    Returns whether the uglify-js tool is available. t   whicht   uglifyjsN(   t
   subprocesst   check_output(    (    (    s   ../tools/uglify_js.pyt   check_available   s    c         C   s   d g } | j  |   | j  d d g  | r< | | 7} n  t j d d j |   y t j |  SWn t j k
 r} d SXd S(   s  
    Prepares command-line call to uglify-js compiler.

    Args:
      source_paths: Source paths to build, in order.
      flags: A list of additional flags to pass on to uglify-js.

    Returns:
      The compiled source, as a string, or None if compilation failed.
    R   s   -cs   -ms(   Compiling with the following command: %st    N(   t   extendt   loggingt   infot   joinR   R   t   CalledProcessError(   t   source_pathst   flagst   args(    (    s   ../tools/uglify_js.pyt   compile   s    	(   t   __doc__R   R   R   t   NoneR   (    (    (    s   ../tools/uglify_js.pyt   <module>   s   	