@@ -5,6 +5,7 @@
55module Hakyll.Main
66 ( hakyll
77 , hakyllWith
8+ , hakyllWithExitCode
89 ) where
910
1011
@@ -13,7 +14,7 @@ import System.Console.CmdArgs
1314import qualified System.Console.CmdArgs.Explicit as CA
1415import System.Environment (getProgName)
1516import System.IO.Unsafe (unsafePerformIO)
16−import System.Exit (exitWith)
17+import System.Exit (ExitCode(ExitSuccess), exitWith)
1718
1819--------------------------------------------------------------------------------
1920import qualified Hakyll.Check as Check
@@ -28,12 +29,14 @@ import Hakyll.Core.Rules
2829hakyll :: Rules a -> IO ()
2930hakyll = hakyllWith Config.defaultConfiguration
3031
31−
3232--------------------------------------------------------------------------------
3333-- | A variant of 'hakyll' which allows the user to specify a custom
3434-- configuration
3535hakyllWith :: Config.Configuration -> Rules a -> IO ()
36−hakyllWith conf rules = do
36+hakyllWith conf rules = hakyllWithExitCode conf rules >>= exitWith
37+
38+hakyllWithExitCode :: Config.Configuration -> Rules a -> IO ExitCode
39+hakyllWithExitCode conf rules = do
3740 args' <- cmdArgs (hakyllArgs conf)
3841
3942 let verbosity' = if verbose args' then Logger.Debug else Logger.Message
@@ -42,15 +45,17 @@ hakyllWith conf rules = do
4245
4346 logger <- Logger.new verbosity'
4447 case args' of
45− Build _ -> Commands.build conf logger rules >>= exitWith
46− Check _ _ -> Commands.check conf logger check'
47− Clean _ -> Commands.clean conf logger
48− Deploy _ -> Commands.deploy conf >>= exitWith
49− Help _ -> showHelp
50− Preview _ p -> Commands.preview conf logger rules p
51− Rebuild _ -> Commands.rebuild conf logger rules >>= exitWith
52− Server _ _ _ -> Commands.server conf logger (host args') (port args')
53− Watch _ _ p s -> Commands.watch conf logger (host args') p (not s) rules
48+ Build _ -> Commands.build conf logger rules
49+ Check _ _ -> Commands.check conf logger check' >> ok
50+ Clean _ -> Commands.clean conf logger >> ok
51+ Deploy _ -> Commands.deploy conf
52+ Help _ -> showHelp >> ok
53+ Preview _ p -> Commands.preview conf logger rules p >> ok
54+ Rebuild _ -> Commands.rebuild conf logger rules
55+ Server _ _ _ -> Commands.server conf logger (host args') (port args') >> ok
56+ Watch _ _ p s -> Commands.watch conf logger (host args') p (not s) rules >> ok
57+ where
58+ ok = return ExitSuccess
5459
5560
5661--------------------------------------------------------------------------------