forked from elm-lang/elm-reactor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setup.hs
43 lines (33 loc) · 1.14 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Distribution.Simple
import Distribution.Simple.Setup
import Distribution.Simple.LocalBuildInfo
import Distribution.PackageDescription
import System.IO
import System.Exit
import System.Process
import Control.Monad
import System.FilePath
import System.Directory
main :: IO ()
main =
defaultMainWithHooks simpleUserHooks { postBuild = myPostBuild }
myPostBuild :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
myPostBuild args flags pd lbi =
do putStrLn "Custom build step: creating and collecting all static resources"
buildSideBar
src <- readFile ("frontend" </> "debugger-implementation.js")
appendFile output src
postBuild simpleUserHooks args flags pd lbi
output :: FilePath
output =
"assets" </> "_reactor" </> "debug.js"
buildSideBar :: IO ()
buildSideBar =
do (exitCode, out, err) <-
readProcessWithExitCode "elm-make" [ "--yes", "frontend" </> "SideBar.elm", "--output=" ++ output ] ""
case exitCode of
ExitSuccess ->
return ()
ExitFailure _ ->
do hPutStrLn stderr ("Failed to build SideBar.elm\n\n" ++ out ++ err)
exitFailure