1{-# LANGUAGE DeriveDataTypeable #-}
4import Data.Either (lefts, rights)
5import Data.List (intersect, intercalate)
6import Data.Maybe (fromMaybe)
7import Data.Version (showVersion)
8import System.Console.CmdArgs
10import Text.Blaze.Html.Renderer.String (renderHtml)
12import qualified Text.Jasmine as JS
13import qualified Data.ByteString.Lazy.Char8 as BS
24 , runtime :: Maybe FilePath
27 , import_js :: [FilePath]
28 , generate_noscript :: Bool
30 , output_directory :: Maybe FilePath
32 deriving (Data,Typeable,Show,Eq)
34elm = ELM { make = False &= help "automatically compile dependencies."
35 , files = def &= args &= typ "FILES"
36 , runtime = Nothing &= typFile &=
37 help "Specify a custom location for Elm's runtime system."
38 , separate_js = False &= help "Compile to separate HTML and JS files."
39 , only_js = False &= help "Compile only to JavaScript."
40 , import_js = [] &= typFile &= help "Include a JavaScript file before the body of the Elm program. Can be used many times. Files will be included in the given order."
41 , generate_noscript = True &= help "Add generated <noscript> tag to HTML output."
42 , minify = False &= help "Minify generated JavaScript"
43 , output_directory = Nothing &= typFile &= help "Output files to directory specified. Defaults to the location of original file."
45 help "Compile Elm programs to HTML, CSS, and JavaScript." &=
46 summary ("The Elm Compiler " ++ showVersion version ++ ", (c) Evan Czaplicki")
50 mini <- getDataFileName ("elm-runtime-" ++ showVersion version ++ ".js")
53compileArgs mini (ELM _ [] _ _ _ _ _ _ _) =
54 putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
55compileArgs mini (ELM make files rtLoc split only js nscrpt isMini outputDir) =
56 mapM_ (fileTo isMini make what js nscrpt outputDir loc) files
57 where loc = fromMaybe mini rtLoc
62data What = JS | HTML | Split
64fileTo isMini make what jsFiles noscript outputDir rtLoc file = do
65 let jsStyle = if isMini then Minified else Readable
66 formatJS = if isMini then BS.unpack . JS.minify . BS.pack else id
67 ems <- if make then build file else do src <- readFile file
68 return (fmap (:[]) (buildFromSource src))
69 jss <- concat `fmap` mapM readFile jsFiles
71 Left err -> putStrLn $ "Error while compiling " ++ file ++ ":\n" ++ err
73 let path = fromMaybe "" outputDir </> file
74 js = replaceExtension path ".js"
75 html = replaceExtension path ".html"
76 txt = jss ++ concatMap jsModule ms
78 JS -> writeFile js (formatJS txt)
79 HTML -> writeFile html . renderHtml $
80 modulesToHtml jsStyle "" rtLoc jss noscript ms
82 do writeFile html . renderHtml $ linkedHtml rtLoc js ms
83 writeFile js (formatJS txt)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list