git.iko.soy/lynxjs-elm/compiler
on master help sign in
Fix Dev command: enable stdout line buffering and suppress serve output
2fae2e7iko
terminal/src/Dev.hs+7−2
@@ -15,6 +15,7 @@ import qualified Data.Time.Clock.POSIX as Time
15import qualified System.Directory as Dir
15import qualified System.Directory as Dir
16import qualified System.Exit as SysExit
16import qualified System.Exit as SysExit
17import System.FilePath ((</>), takeExtension, takeFileName)
17import System.FilePath ((</>), takeExtension, takeFileName)
18+import System.IO (hSetBuffering, stdout, BufferMode(..))
18import qualified System.Process as Process
19import qualified System.Process as Process
19
20
20import qualified BackgroundWriter as BW
21import qualified BackgroundWriter as BW
@@ -44,7 +45,8 @@ data Flags =
44
45
45run :: FilePath -> Flags -> IO ()
46run :: FilePath -> Flags -> IO ()
46run path (Flags maybePort) =
47run path (Flags maybePort) =
48+ do hSetBuffering stdout LineBuffering
47− do maybeRoot <- Stuff.findRoot
49+ maybeRoot <- Stuff.findRoot
48 case maybeRoot of
50 case maybeRoot of
49 Nothing ->
51 Nothing ->
50 putStrLn "I cannot find an elm.json file. Run `lynxjs-elm init` first."
52 putStrLn "I cannot find an elm.json file. Run `lynxjs-elm init` first."
@@ -79,7 +81,10 @@ run path (Flags maybePort) =
79 -- Start static file server in background
81 -- Start static file server in background
80 let distDir = bundlerDir </> "dist"
82 let distDir = bundlerDir </> "dist"
81 let serveProc = (Process.proc "npx" ["serve", "-l", show port, "-n", distDir])
83 let serveProc = (Process.proc "npx" ["serve", "-l", show port, "-n", distDir])
82− { Process.cwd = Just bundlerDir }
84+ { Process.cwd = Just bundlerDir
85+ , Process.std_out = Process.NoStream
86+ , Process.std_err = Process.NoStream
87+ }
83 (_, _, _, serveHandle) <- Process.createProcess serveProc
88 (_, _, _, serveHandle) <- Process.createProcess serveProc
84
89
85 -- Print bundle URL
90 -- Print bundle URL