on master help sign in
Merge pull request #154 from tunixman/master

Have Build and Rebuild commands exit with status

commit2ef7fee7978af45416634ae9a024523a2f6f0e10 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateWed 22 May 2013, 03:03 (13 years ago) parent24307518c73820
2 files changed+10−16
src/Hakyll/Commands.hs+7−13 src/Hakyll/Main.hs+3−3
src/Hakyll/Commands.hs+7−13
@@ -13,8 +13,8 @@ module Hakyll.Commands
1313
1414
1515--------------------------------------------------------------------------------
16−import System.Exit (exitWith)
17−
16+import System.Exit (exitWith, ExitCode)
17+import Control.Applicative
1818
1919--------------------------------------------------------------------------------
2020import qualified Hakyll.Check as Check
@@ -25,7 +25,6 @@ import Hakyll.Core.Rules.Internal
2525import Hakyll.Core.Runtime
2626import Hakyll.Core.Util.File
2727
28−
2928--------------------------------------------------------------------------------
3029#ifdef PREVIEW_SERVER
3130import Hakyll.Preview.Poll
@@ -35,11 +34,8 @@ import Hakyll.Preview.Server
3534
3635--------------------------------------------------------------------------------
3736-- | Build the site
38−build :: Configuration -> Verbosity -> Rules a -> IO ()
39−build conf verbosity rules = do
40− _ <- run conf verbosity rules
41− return ()
42−
37+build :: Configuration -> Verbosity -> Rules a -> IO ExitCode
38+build conf verbosity rules = fst <$> run conf verbosity rules
4339
4440--------------------------------------------------------------------------------
4541-- | Run the checker and exit
@@ -78,11 +74,9 @@ preview _ _ _ _ = previewServerDisabled
7874
7975--------------------------------------------------------------------------------
8076-- | Rebuild the site
81−rebuild :: Configuration -> Verbosity -> Rules a -> IO ()
82−rebuild conf verbosity rules = do
83− clean conf
84− build conf verbosity rules
85−
77+rebuild :: Configuration -> Verbosity -> Rules a -> IO ExitCode
78+rebuild conf verbosity rules =
79+ clean conf >> build conf verbosity rules
8680
8781--------------------------------------------------------------------------------
8882-- | Start a server
src/Hakyll/Main.hs+3−3
@@ -13,7 +13,7 @@ import System.Console.CmdArgs
1313import qualified System.Console.CmdArgs.Explicit as CA
1414import System.Environment (getProgName)
1515import System.IO.Unsafe (unsafePerformIO)
16−
16+import System.Exit (exitWith)
1717
1818--------------------------------------------------------------------------------
1919import qualified Hakyll.Check as Check
@@ -41,13 +41,13 @@ hakyllWith conf rules = do
4141 if internal_links args' then Check.InternalLinks else Check.All
4242
4343 case args' of
44− Build _ -> Commands.build conf verbosity' rules
44+ Build _ -> Commands.build conf verbosity' rules >>= exitWith
4545 Check _ _ -> Commands.check conf verbosity' check'
4646 Clean _ -> Commands.clean conf
4747 Deploy _ -> Commands.deploy conf
4848 Help _ -> showHelp
4949 Preview _ p -> Commands.preview conf verbosity' rules p
50− Rebuild _ -> Commands.rebuild conf verbosity' rules
50+ Rebuild _ -> Commands.rebuild conf verbosity' rules >>= exitWith
5151 Server _ _ -> Commands.server conf (port args')
5252
5353