@@ -221,6 +221,10 @@ atomicPutStrLn :: String -> IO ()
221221atomicPutStrLn str =
222222 withMVar printLock (\ _ -> hPutStr stdout (str <> " \n " ) >> hFlush stdout)
223223
224+ atomicPutStrLn_ :: Text -> IO ()
225+ atomicPutStrLn_ text =
226+ atomicPutStrLn $ T. unpack text
227+
224228atomicPutStrLnDebug :: String -> IO ()
225229atomicPutStrLnDebug s = do
226230 onlyWhen (isDebug_) $ atomicPutStrLn s
@@ -380,23 +384,29 @@ bashq command =
380384c_ :: String -> [String ] -> String -> IO String
381385c_ bin args input = do
382386 atomicPutStrLnDebug $ " 🤖 " <> bin <> " " <> show args <> " " <> input
383- (exit, stdout, stderr ) <- System.Process. readProcessWithExitCode bin args input
387+ (exit, stdOut, stdErr ) <- System.Process. readProcessWithExitCode bin args input
384388 res <-
385- if Prelude. length stderr > 0
386- then pure stderr
387- else pure stdout
388- atomicPutStrLnDebug $ " └── " <> res
389- pure res
389+ if Prelude. length stdErr > 0
390+ then pure stdErr
391+ else pure stdOut
392+ -- This doesn't quite work for debugging because bash will honour the sequence codes of the output
393+ -- which gives us confusing results. I.e. Elm compilation clears the buffer during operation
394+ -- onlyWhen (Prelude.length stdErr > 0) $ atomicPutStrLnDebug $ "└── stdErr: " <> stdErr
395+ -- onlyWhen (Prelude.length stdOut > 0) $ atomicPutStrLnDebug $ "└── stdOut: " <> stdOut
396+ -- This doesn't happen with the show instance as it escapes sequences inside the string
397+ atomicPutStrLnDebug $ " └── " <> show (exit, stdOut, stdErr)
398+ pure $ show (exit, stdOut, stdErr)
399+
390400
391401cq_ :: String -> [String ] -> String -> IO String
392402cq_ bin args input = do
393403 atomicPutStrLnDebug $ " 🤖 " <> bin <> " " <> show args <> " " <> input
394- (exit, stdout, stderr ) <- System.Process. readProcessWithExitCode bin args input
404+ (exit, stdOut, stdErr ) <- System.Process. readProcessWithExitCode bin args input
395405 res <-
396- if Prelude. length stderr > 0
397- then pure stderr
398- else pure stdout
399- pure res
406+ if Prelude. length stdErr > 0
407+ then pure stdErr
408+ else pure stdOut
409+ pure $ show (exit, stdOut, stdErr)
400410
401411
402412requireBinary :: String -> IO FilePath
0 commit comments