diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-01-15 17:15:46 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-01-15 17:15:46 +0100 |
commit | e53ca6724c8f5715792ad6b269ede52f21eb606c (patch) | |
tree | 0784fda9450175cf1ffefabc8bacbe959026e82f | |
parent | cf47549f0a975c427706af9aef75fc4346c330ae (diff) | |
download | hakyll-e53ca6724c8f5715792ad6b269ede52f21eb606c.tar.gz |
Make run return ExitCode
-rw-r--r-- | src/Hakyll/Commands.hs | 17 | ||||
-rw-r--r-- | src/Hakyll/Core/Runtime.hs | 9 | ||||
-rw-r--r-- | web/site.hs | 3 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs index 61e40b8..4c60783 100644 --- a/src/Hakyll/Commands.hs +++ b/src/Hakyll/Commands.hs @@ -13,7 +13,7 @@ module Hakyll.Commands -------------------------------------------------------------------------------- -import System.Exit (exitWith) +import System.Exit (ExitCode (ExitSuccess), exitWith) import System.Process (system) @@ -69,15 +69,16 @@ clean conf = do preview :: Configuration -> Verbosity -> Rules a -> Int -> IO () #ifdef PREVIEW_SERVER preview conf verbosity rules port = do - -- Fork a thread polling for changes - _ <- forkIO $ previewPoll conf update - - -- Run the server in the main thread - server conf port + -- Run the server in a separate thread + _ <- forkIO $ server conf port + previewPoll conf update where update = do - ruleSet <- run conf verbosity rules - return $ map toFilePath $ S.toList $ rulesResources ruleSet + (exitCode, ruleSet) <- run conf verbosity rules + case exitCode of + ExitSuccess -> return $ map toFilePath $ S.toList $ + rulesResources ruleSet + _ -> exitWith exitCode #else preview _ _ _ _ = previewServerDisabled #endif diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs index 1b83692..39d72a7 100644 --- a/src/Hakyll/Core/Runtime.hs +++ b/src/Hakyll/Core/Runtime.hs @@ -17,7 +17,7 @@ import qualified Data.Map as M import Data.Monoid (mempty) import Data.Set (Set) import qualified Data.Set as S -import System.Exit (ExitCode (..), exitWith) +import System.Exit (ExitCode (..)) import System.FilePath ((</>)) @@ -41,8 +41,7 @@ import Hakyll.Core.Writable -------------------------------------------------------------------------------- --- | TODO Make this return exit code? -run :: Configuration -> Verbosity -> Rules a -> IO RuleSet +run :: Configuration -> Verbosity -> Rules a -> IO (ExitCode, RuleSet) run config verbosity rules = do -- Initialization logger <- Logger.new verbosity @@ -82,7 +81,7 @@ run config verbosity rules = do Left e -> do Logger.error logger e Logger.flush logger - exitWith $ ExitFailure 1 + return (ExitFailure 1, ruleSet) Right (_, s, _) -> do Store.set store factsKey $ runtimeFacts s @@ -91,7 +90,7 @@ run config verbosity rules = do removeDirectory $ tmpDirectory config Logger.flush logger - return ruleSet + return (ExitSuccess, ruleSet) where factsKey = ["Hakyll.Core.Runtime.run", "facts"] diff --git a/web/site.hs b/web/site.hs index 0f99af2..7c9ee4f 100644 --- a/web/site.hs +++ b/web/site.hs @@ -85,7 +85,8 @@ main = hakyllWith config $ do config :: Configuration config = defaultConfiguration { deployCommand = "rsync --checksum -ave 'ssh -p 2222' \ - \_site/* jaspervdj@jaspervdj.be:jaspervdj.be/tmp/hakyll4" + \_site/* \ + \jaspervdj@jaspervdj.be:jaspervdj.be/hakyll/hakyll4" } |