From 89545102a0c35d81eb88d5a7e949046702b5c211 Mon Sep 17 00:00:00 2001 From: Simon Hengel Date: Fri, 16 Mar 2018 18:07:49 +0800 Subject: [PATCH] Exit with `exitFailure` when generation of `.cabal` file fails --- CHANGELOG.md | 4 ++++ src/Hpack.hs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 147a9d10..8fffee36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## next + - Exit with `exitFailure` on `AlreadyGeneratedByNewerHpack` or + `ExistingCabalFileWasModifiedManually` in `Hpack.printResult` + ## Changes in 0.28.1 - GHC 8.4.1 compatibility diff --git a/src/Hpack.hs b/src/Hpack.hs index f55920b2..3267ad92 100644 --- a/src/Hpack.hs +++ b/src/Hpack.hs @@ -139,6 +139,11 @@ printResult verbose r = do OutputUnchanged -> resultCabalFile r ++ " is up-to-date" AlreadyGeneratedByNewerHpack -> resultCabalFile r ++ " was generated with a newer version of hpack, please upgrade and try again." ExistingCabalFileWasModifiedManually -> resultCabalFile r ++ " was modified manually, please use --force to overwrite." + case resultStatus r of + Generated -> return () + OutputUnchanged -> return () + AlreadyGeneratedByNewerHpack -> exitFailure + ExistingCabalFileWasModifiedManually -> exitFailure printWarnings :: [String] -> IO () printWarnings = mapM_ $ Utf8.hPutStrLn stderr . ("WARNING: " ++)