on master help sign in
Make run return ExitCode
commite53ca6724c8f5715792ad6b269ede52f21eb606c authorJasper Van der Jeugt <m@jaspervdj.be> dateTue 15 Jan 2013, 17:15 (14 years ago) parentcf47549
3 files changed+15−14
src/Hakyll/Commands.hs+9−8 src/Hakyll/Core/Runtime.hs+4−5 web/site.hs+2−1
src/Hakyll/Commands.hs+9−8
@@ -13,7 +13,7 @@ module Hakyll.Commands
1313
1414
1515--------------------------------------------------------------------------------
16−import System.Exit (exitWith)
16+import System.Exit (ExitCode (ExitSuccess), exitWith)
1717import System.Process (system)
1818
1919
@@ -69,15 +69,16 @@ clean conf = do
6969preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
7070#ifdef PREVIEW_SERVER
7171preview conf verbosity rules port = do
72− -- Fork a thread polling for changes
73− _ <- forkIO $ previewPoll conf update
74−
75− -- Run the server in the main thread
76− server conf port
72+ -- Run the server in a separate thread
73+ _ <- forkIO $ server conf port
74+ previewPoll conf update
7775 where
7876 update = do
79− ruleSet <- run conf verbosity rules
80− return $ map toFilePath $ S.toList $ rulesResources ruleSet
77+ (exitCode, ruleSet) <- run conf verbosity rules
78+ case exitCode of
79+ ExitSuccess -> return $ map toFilePath $ S.toList $
80+ rulesResources ruleSet
81+ _ -> exitWith exitCode
8182#else
8283preview _ _ _ _ = previewServerDisabled
8384#endif
src/Hakyll/Core/Runtime.hs+4−5
@@ -17,7 +17,7 @@ import qualified Data.Map as M
1717import Data.Monoid (mempty)
1818import Data.Set (Set)
1919import qualified Data.Set as S
20−import System.Exit (ExitCode (..), exitWith)
20+import System.Exit (ExitCode (..))
2121import System.FilePath ((</>))
2222
2323
@@ -41,8 +41,7 @@ import Hakyll.Core.Writable
4141
4242
4343--------------------------------------------------------------------------------
44−-- | TODO Make this return exit code?
45−run :: Configuration -> Verbosity -> Rules a -> IO RuleSet
44+run :: Configuration -> Verbosity -> Rules a -> IO (ExitCode, RuleSet)
4645run config verbosity rules = do
4746 -- Initialization
4847 logger <- Logger.new verbosity
@@ -82,7 +81,7 @@ run config verbosity rules = do
8281 Left e -> do
8382 Logger.error logger e
8483 Logger.flush logger
85− exitWith $ ExitFailure 1
84+ return (ExitFailure 1, ruleSet)
8685
8786 Right (_, s, _) -> do
8887 Store.set store factsKey $ runtimeFacts s
@@ -91,7 +90,7 @@ run config verbosity rules = do
9190 removeDirectory $ tmpDirectory config
9291
9392 Logger.flush logger
94− return ruleSet
93+ return (ExitSuccess, ruleSet)
9594 where
9695 factsKey = ["Hakyll.Core.Runtime.run", "facts"]
9796
web/site.hs+2−1
@@ -85,7 +85,8 @@ main = hakyllWith config $ do
8585config :: Configuration
8686config = defaultConfiguration
8787 { deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
88− \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
88+ \_site/* \
89+ \jaspervdj@jaspervdj.be:jaspervdj.be/hakyll/hakyll4"
8990 }
9091
9192