diff options
author | Svyatoslav Gryaznov <nightuser@ya.ru> | 2016-07-05 16:45:29 +0300 |
---|---|---|
committer | Svyatoslav Gryaznov <nightuser@ya.ru> | 2016-07-05 16:45:29 +0300 |
commit | 637872f6ea4a37d2a4162c95d7cb0304efc41d19 (patch) | |
tree | 8e4fb29fa1537392bc4a41405c253d538b65bb95 /src | |
parent | fd5e7df4896845a113d03cefac9a710d2252aa19 (diff) | |
download | stylish-haskell-637872f6ea4a37d2a4162c95d7cb0304efc41d19.tar.gz |
Add newline format option
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs index e64b291..fdaf0de 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -123,7 +123,12 @@ file sa conf mfp = do write old new = case mfp of Nothing -> putStr new Just _ | not (saInPlace sa) -> putStr new - Just path | not (null new) && old /= new -> writeFile path new + Just path | not (null new) && old /= new -> + IO.withFile path IO.WriteMode $ \h -> do + let nl = configNewline conf + let mode = IO.NewlineMode nl nl + IO.hSetNewlineMode h mode + IO.hPutStr h new _ -> return () readUTF8File :: FilePath -> IO String |