diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2017-01-07 19:56:57 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2017-01-07 19:57:22 +0100 |
commit | a1e6b73582d96fe5e8a31ce585f1d85c1fa0babd (patch) | |
tree | da8a5b376b945a754c69067234e99738bccdad2c /src | |
parent | 7d29962850f66ec62945a5fe784e73194a942526 (diff) | |
download | stylish-haskell-a1e6b73582d96fe5e8a31ce585f1d85c1fa0babd.tar.gz |
On errors, show error and exit with code 1
See #146
Diffstat (limited to 'src')
-rw-r--r-- | src/Main.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs index d481517..8eeb7ab 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -10,6 +10,7 @@ import Data.Monoid ((<>)) import Data.Version (showVersion) import qualified Options.Applicative as OA import qualified Paths_stylish_haskell +import System.Exit (exitFailure) import qualified System.IO as IO import qualified System.IO.Strict as IO.Strict @@ -117,8 +118,10 @@ file sa conf mfp = do let result = runSteps (configLanguageExtensions conf) mfp (configSteps conf) $ lines contents case result of - Left err -> IO.hPutStrLn IO.stderr err >> write contents contents Right ok -> write contents $ unlines ok + Left err -> do + IO.hPutStrLn IO.stderr err + exitFailure where write old new = case mfp of Nothing -> putStrNewline new |