Skip to content

Commit

Permalink
Use exit code 0 when printing sources back to stdout
Browse files Browse the repository at this point in the history
This is temporary fix while I'm waiting for this issue to be resolved:
danstiner#19

It seems safe to assume that if we're printing sources to stdout we're
not running under CI semantics (for CI I guess printing file names would
be enough), and tools line Neoformat treat exit codes other than 0 as
formatting failure.
  • Loading branch information
alex-kononovich committed Aug 24, 2017
1 parent 0f11b9d commit f5c2078
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ main = do
runFormatter :: Formatter -> Options -> IO Bool
runFormatter formatter options =
anyStrict
sourceChangedOrHasSuggestions
(sourceChangedOrHasSuggestions options)
(inputFiles >-> P.map reformat >-> P.mapM writeOutput)
where
anyStrict :: Monad m => (a -> Bool) -> Producer a m () -> m Bool
Expand Down Expand Up @@ -67,7 +67,10 @@ readSource path = HaskellSource <$> readFile path
readStdin :: IO HaskellSource
readStdin = HaskellSource <$> getContents

sourceChangedOrHasSuggestions :: ReformatResult -> Bool
sourceChangedOrHasSuggestions (Reformat input source reformatted) =
not (null (suggestions reformatted)) ||
source /= reformattedSource reformatted
sourceChangedOrHasSuggestions :: Options -> ReformatResult -> Bool
sourceChangedOrHasSuggestions options (Reformat input source reformatted) =
case (Options.optAction options) of
PrintSources -> False
_ ->
not (null (suggestions reformatted)) ||
source /= reformattedSource reformatted

0 comments on commit f5c2078

Please sign in to comment.