packages feed

elm-server 0.9.0.2 → 0.10.1

raw patch · 3 files changed

+35/−20 lines, 3 filesdep ~Elm

Dependency ranges changed: Elm

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c)2012, Evan Czaplicki+Copyright (c)2012-2013, Evan Czaplicki  All rights reserved. 
Server.hs view
@@ -1,7 +1,6 @@- module Main where -import Control.Monad (msum,guard)+import Control.Monad (msum,guard,when) import Control.Monad.Trans (MonadIO(liftIO)) import Data.List (isPrefixOf, isSuffixOf, (\\)) import Data.Version (showVersion)@@ -13,7 +12,7 @@ import System.FilePath import System.Process import GHC.IO.Handle-import qualified Language.Elm as Elm+import qualified Elm.Internal.Paths as ElmPaths import Paths_elm_server  runtime = "/elm-runtime.js"@@ -35,23 +34,34 @@ pageTitle = dropExtension . takeBaseName  serveElm :: FilePath -> ServerPartT IO Response-serveElm fp = do-  guard (takeExtension fp == ".elm")-  let file = tail fp-      args = [ "--make" ,"--runtime=" ++ runtime, "--cache-dir=elm-server-cache", file ]-  (_, stdout, _, handle) <- liftIO $ createProcess $ (proc "elm" args) { std_out = CreatePipe }+serveElm fp =+  do fileExists <- liftIO $ doesFileExist file+     guard (fileExists && takeExtension fp == ".elm")+     onSuccess compile serve+  where+    file = tail fp++    compile = liftIO $ createProcess $ (proc "elm" args) { std_out = CreatePipe }+        where args = [ "--make", "--runtime=" ++ runtime, file ]++    serve = serveFile (asContentType "text/html")+                      ("build" </> replaceExtension file "html")++onSuccess action success = do+  (_, stdout, _, handle) <- action   exitCode <- liftIO $ waitForProcess handle-  liftIO $ removeDirectoryRecursive "elm-server-cache"   case (exitCode, stdout) of+    (ExitFailure 127, _) ->+        badRequest $ toResponse "Error: elm binary not found in your path."     (ExitFailure _, Just out) ->         do str <- liftIO $ hGetContents out            badRequest $ toResponse str     (ExitFailure _, Nothing) ->         badRequest $ toResponse "See command line for error message."-    (ExitSuccess, _) ->-        serveFile (asContentType "text/html") ("build" </> replaceExtension file "html")+    (ExitSuccess, _) -> success -serveLib :: FilePath -> [Char] -> ServerPartT IO Response++serveLib :: FilePath -> String -> ServerPartT IO Response serveLib libLoc fp = do   guard (fp == runtime)   serveFile (asContentType "application/javascript") libLoc@@ -63,9 +73,11 @@ parse ("--help":_) = putStrLn usage parse ("--version":_) = putStrLn ("The Elm Server " ++ showVersion version) parse args =-  case null remainingArgs of-    True -> serve portNumber =<< elmRuntime-    False -> putStrLn usageMini+  if null remainingArgs then+      serve portNumber elmRuntime+  else+      putStrLn usageMini+   where     runtimeArg = filter (isPrefixOf "--runtime-location=") args     portArg = filter (isPrefixOf "--port=") args@@ -73,7 +85,10 @@      argValue arg = tail $ dropWhile (/= '=') (head arg)     portNumber = if null portArg then 8000 else read (argValue portArg) :: Int-    elmRuntime = if null runtimeArg then Elm.runtime else return $ argValue runtimeArg+    elmRuntime = if null runtimeArg then+                     ElmPaths.runtime+                 else+                     argValue runtimeArg  usageMini :: String usageMini =
elm-server.cabal view
@@ -1,5 +1,5 @@ Name:                elm-server-Version:             0.9.0.2+Version:             0.10.1 Synopsis:            The Elm language server. Description:         This package provides a standalone, Happstack-based Elm server. @@ -10,7 +10,7 @@  Author:              Evan Czaplicki Maintainer:          info@elm-lang.org-Copyright:           Copyright: (c) 2011-2012 Evan Czaplicki+Copyright:           Copyright: (c) 2011-2013 Evan Czaplicki  Category:            Compiler, Language @@ -36,5 +36,5 @@                        happstack-server,                        deepseq,                        filepath,-                       Elm >= 0.9.0.2,+                       Elm >= 0.10.1,                        process