fix:demo: avoid breaking asciinema 2.3.0 (fix #2094)

We were adding a trailing newline, which causes asciinema 2.3.0 to
show a JSON decode error.
This commit is contained in:
Simon Michael 2023-10-23 13:59:25 +01:00
parent 63d41b30db
commit d8021ef754

View File

@ -148,8 +148,11 @@ printDemos = putStrLn $ unlines $
-- | Run asciinema play with the given speed and idle limit, passing the given content to its stdin.
runAsciinemaPlay :: Float -> Float -> ByteString -> [String] -> IO ()
runAsciinemaPlay speed idlelimit content args =
withSystemTempFile "hledger-cast" $ \f h -> do -- try piping to stdin also
B.hPutStrLn h content >> hClose h
-- XXX try piping to stdin also
withSystemTempFile "hledger-cast" $ \f h -> do
-- don't add an extra newline here, it breaks asciinema 2.3.0 (#2094).
-- XXX we could try harder and strip excess newlines/carriage returns+linefeeds here
B.hPutStr h content >> hClose h
callProcess "asciinema" (dbg8With (("asciinema: "++).unwords) $ concat [
["play"]
,["-s"<> showwithouttrailingzero speed]