@@ -24,11 +24,14 @@ import Snap.Util.FileServe
2424
2525data Flags = Flags
2626 { port :: Int
27+ , runtime :: Maybe FilePath
2728 } deriving (Data,Typeable,Show,Eq)
2829
2930flags :: Flags
3031flags = Flags
3132 { port = 8000 &= help "set the port of the server"
33+ , runtime = Nothing &= typFile
34+ &= help "Specify a custom location for Elm's runtime system."
3235 } &= help "Quickly reload Elm projects in your browser. Just refresh to recompile.\n\
3336 \It serves static files and freshly recompiled Elm files."
3437 &= helpArg [explicit, name "help", name "h"]
@@ -49,7 +52,7 @@ main = do
4952 putStrLn $ "Elm Server " ++ Version.showVersion version ++
5053 ": Just refresh a page to recompile it!"
5154 httpServe (setPort (port cargs) config) $
52− serveRuntime
55+ serveRuntime (maybe Elm.runtime id (runtime cargs))
5356 <|> serveElm
5457 <|> serveDirectoryWith directoryConfig "."
5558
@@ -74,14 +77,14 @@ indexStyle =
7477 \th { background:rgb(90,99,120); color:white; text-align:left;\
7578 \ padding:10px; font-weight:normal; }"
7679
77−runtime :: String
78−runtime = "elm-runtime.js"
80+runtimeName :: String
81+runtimeName = "elm-runtime.js"
7982
80−serveRuntime :: Snap ()
81−serveRuntime =
83+serveRuntime :: FilePath -> Snap ()
84+serveRuntime runtimePath =
8285 do file <- BSC.unpack . rqPathInfo <$> getRequest
83− guard (file == runtime)
84− serveFileAs "application/javascript" Elm.runtime
86+ guard (file == runtimeName)
87+ serveFileAs "application/javascript" runtimePath
8588
8689serveElm :: Snap ()
8790serveElm =
@@ -91,7 +94,7 @@ serveElm =
9194 onSuccess (compile file) (serve file)
9295 where
9396 compile file =
94− let elmArgs = [ "--make", "--runtime=" ++ runtime, file ]
97+ let elmArgs = [ "--make", "--runtime=" ++ runtimeName, file ]
9598 in createProcess $ (proc "elm" elmArgs) { std_out = CreatePipe }
9699
97100 serve file =