on master help sign in
Make run return ExitCode
e53ca67Jasper Van der Jeugt
src/Hakyll/Commands.hs+9−8
@@ -13,7 +13,7 @@ module Hakyll.Commands
13
13
14
14
15--------------------------------------------------------------------------------
15--------------------------------------------------------------------------------
16−import System.Exit (exitWith)
16+import System.Exit (ExitCode (ExitSuccess), exitWith)
17import System.Process (system)
17import System.Process (system)
18
18
19
19
@@ -69,15 +69,16 @@ clean conf = do
69preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
69preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
70#ifdef PREVIEW_SERVER
70#ifdef PREVIEW_SERVER
71preview conf verbosity rules port = do
71preview conf verbosity rules port = do
72− -- Fork a thread polling for changes
72+ -- Run the server in a separate thread
73+ _ <- forkIO $ server conf port
73− _ <- forkIO $ previewPoll conf update
74+ previewPoll conf update
74−
75− -- Run the server in the main thread
76− server conf port
77 where
75 where
78 update = do
76 update = do
79− ruleSet <- run conf verbosity rules
77+ (exitCode, ruleSet) <- run conf verbosity rules
78+ case exitCode of
80− return $ map toFilePath $ S.toList $ rulesResources ruleSet
79+ ExitSuccess -> return $ map toFilePath $ S.toList $
80+ rulesResources ruleSet
81+ _ -> exitWith exitCode
81#else
82#else
82preview _ _ _ _ = previewServerDisabled
83preview _ _ _ _ = previewServerDisabled
83#endif
84#endif
src/Hakyll/Core/Runtime.hs+4−5
@@ -17,7 +17,7 @@ import qualified Data.Map as M
17import Data.Monoid (mempty)
17import Data.Monoid (mempty)
18import Data.Set (Set)
18import Data.Set (Set)
19import qualified Data.Set as S
19import qualified Data.Set as S
20−import System.Exit (ExitCode (..), exitWith)
20+import System.Exit (ExitCode (..))
21import System.FilePath ((</>))
21import System.FilePath ((</>))
22
22
23
23
@@ -41,8 +41,7 @@ import Hakyll.Core.Writable
41
41
42
42
43--------------------------------------------------------------------------------
43--------------------------------------------------------------------------------
44−-- | TODO Make this return exit code?
45−run :: Configuration -> Verbosity -> Rules a -> IO RuleSet
44+run :: Configuration -> Verbosity -> Rules a -> IO (ExitCode, RuleSet)
46run config verbosity rules = do
45run config verbosity rules = do
47 -- Initialization
46 -- Initialization
48 logger <- Logger.new verbosity
47 logger <- Logger.new verbosity
@@ -82,7 +81,7 @@ run config verbosity rules = do
82 Left e -> do
81 Left e -> do
83 Logger.error logger e
82 Logger.error logger e
84 Logger.flush logger
83 Logger.flush logger
85− exitWith $ ExitFailure 1
84+ return (ExitFailure 1, ruleSet)
86
85
87 Right (_, s, _) -> do
86 Right (_, s, _) -> do
88 Store.set store factsKey $ runtimeFacts s
87 Store.set store factsKey $ runtimeFacts s
@@ -91,7 +90,7 @@ run config verbosity rules = do
91 removeDirectory $ tmpDirectory config
90 removeDirectory $ tmpDirectory config
92
91
93 Logger.flush logger
92 Logger.flush logger
94− return ruleSet
93+ return (ExitSuccess, ruleSet)
95 where
94 where
96 factsKey = ["Hakyll.Core.Runtime.run", "facts"]
95 factsKey = ["Hakyll.Core.Runtime.run", "facts"]
97
96
web/site.hs+2−1
@@ -85,7 +85,8 @@ main = hakyllWith config $ do
85config :: Configuration
85config :: Configuration
86config = defaultConfiguration
86config = defaultConfiguration
87 { deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
87 { deployCommand = "rsync --checksum -ave 'ssh -p 2222' \
88+ \_site/* \
88− \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4"
89+ \jaspervdj@jaspervdj.be:jaspervdj.be/hakyll/hakyll4"
89 }
90 }
90
91
91
92