module Development.Shake.ClosureCompiler ( googleClosureCompiler
                                         ) where

import           Development.Shake
import           Development.Shake.FilePath
import           System.Directory           (createDirectoryIfMissing)

googleClosureCompiler :: [FilePath] -- ^ JavaScript source files
                      -> FilePattern -- ^ File pattern for build output
                      -> Rules ()
googleClosureCompiler sources fp =
    fp %> \out -> do
        need sources
        liftIO $ createDirectoryIfMissing True (takeDirectory out)
        command [] "google-closure-compiler" (sources ++ ["--js_output_file", fp])