summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorSvyatoslav Gryaznov <nightuser@ya.ru>2016-07-06 15:43:07 +0300
committerSvyatoslav Gryaznov <nightuser@ya.ru>2016-07-06 15:43:07 +0300
commit486dcc2da09017b09eeb82001bf0d2cdba5043d0 (patch)
tree20c2c3905f9c39d05c634e0be78f5d6da81717bc /src
parent9ad660b96b3846341b54e7af727e6a9d1fbb6b5a (diff)
downloadstylish-haskell-486dcc2da09017b09eeb82001bf0d2cdba5043d0.tar.gz
Set newline format to `stdout` too
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 73ec12a..d481517 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -121,15 +121,18 @@ file sa conf mfp = do
Right ok -> write contents $ unlines ok
where
write old new = case mfp of
- Nothing -> putStr new
- Just _ | not (saInPlace sa) -> putStr new
+ Nothing -> putStrNewline new
+ Just _ | not (saInPlace sa) -> putStrNewline new
Just path | not (null new) && old /= new ->
IO.withFile path IO.WriteMode $ \h -> do
- let nl = configNewline conf
- let mode = IO.NewlineMode IO.nativeNewline nl
- IO.hSetNewlineMode h mode
+ setNewlineMode h
IO.hPutStr h new
_ -> return ()
+ setNewlineMode h = do
+ let nl = configNewline conf
+ let mode = IO.NewlineMode IO.nativeNewline nl
+ IO.hSetNewlineMode h mode
+ putStrNewline txt = setNewlineMode IO.stdout >> putStr txt
readUTF8File :: FilePath -> IO String
readUTF8File fp =