summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Commands.hs22
-rw-r--r--src/Hakyll/Core/Configuration.hs7
-rw-r--r--src/Hakyll/Main.hs8
3 files changed, 16 insertions, 21 deletions
diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs
index 6d6b0ae..d86fd5c 100644
--- a/src/Hakyll/Commands.hs
+++ b/src/Hakyll/Commands.hs
@@ -13,8 +13,8 @@ module Hakyll.Commands
--------------------------------------------------------------------------------
-import System.Exit (exitWith)
-
+import System.Exit (exitWith, ExitCode)
+import Control.Applicative
--------------------------------------------------------------------------------
import qualified Hakyll.Check as Check
@@ -25,7 +25,6 @@ import Hakyll.Core.Rules.Internal
import Hakyll.Core.Runtime
import Hakyll.Core.Util.File
-
--------------------------------------------------------------------------------
#ifdef PREVIEW_SERVER
import Hakyll.Preview.Poll
@@ -35,11 +34,8 @@ import Hakyll.Preview.Server
--------------------------------------------------------------------------------
-- | Build the site
-build :: Configuration -> Verbosity -> Rules a -> IO ()
-build conf verbosity rules = do
- _ <- run conf verbosity rules
- return ()
-
+build :: Configuration -> Verbosity -> Rules a -> IO ExitCode
+build conf verbosity rules = fst <$> run conf verbosity rules
--------------------------------------------------------------------------------
-- | Run the checker and exit
@@ -78,11 +74,9 @@ preview _ _ _ _ = previewServerDisabled
--------------------------------------------------------------------------------
-- | Rebuild the site
-rebuild :: Configuration -> Verbosity -> Rules a -> IO ()
-rebuild conf verbosity rules = do
- clean conf
- build conf verbosity rules
-
+rebuild :: Configuration -> Verbosity -> Rules a -> IO ExitCode
+rebuild conf verbosity rules =
+ clean conf >> build conf verbosity rules
--------------------------------------------------------------------------------
-- | Start a server
@@ -100,7 +94,7 @@ server _ _ = previewServerDisabled
--------------------------------------------------------------------------------
-- | Upload the site
-deploy :: Configuration -> IO ()
+deploy :: Configuration -> IO ExitCode
deploy conf = deploySite conf conf
diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs
index 70a7a1c..790badc 100644
--- a/src/Hakyll/Core/Configuration.hs
+++ b/src/Hakyll/Core/Configuration.hs
@@ -12,6 +12,7 @@ import Control.Monad (void)
import Data.Default (Default (..))
import Data.List (isPrefixOf, isSuffixOf)
import System.Directory (canonicalizePath)
+import System.Exit (ExitCode)
import System.FilePath (isAbsolute, normalise, takeFileName)
import System.IO.Error (catchIOError)
import System.Process (system)
@@ -65,7 +66,7 @@ data Configuration = Configuration
-- The 'Configuration' object is passed as a parameter to this
-- function.
--
- deploySite :: Configuration -> IO ()
+ deploySite :: Configuration -> IO ExitCode
, -- | Use an in-memory cache for items. This is faster but uses more
-- memory.
inMemoryCache :: Bool
@@ -84,8 +85,8 @@ defaultConfiguration = Configuration
, tmpDirectory = "_cache/tmp"
, providerDirectory = "."
, ignoreFile = ignoreFile'
- , deployCommand = "echo 'No deploy command specified'"
- , deploySite = void . system . deployCommand
+ , deployCommand = "echo 'No deploy command specified' && exit 1"
+ , deploySite = system . deployCommand
, inMemoryCache = True
}
where
diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs
index 527548d..7e50418 100644
--- a/src/Hakyll/Main.hs
+++ b/src/Hakyll/Main.hs
@@ -13,7 +13,7 @@ import System.Console.CmdArgs
import qualified System.Console.CmdArgs.Explicit as CA
import System.Environment (getProgName)
import System.IO.Unsafe (unsafePerformIO)
-
+import System.Exit (exitWith)
--------------------------------------------------------------------------------
import qualified Hakyll.Check as Check
@@ -41,13 +41,13 @@ hakyllWith conf rules = do
if internal_links args' then Check.InternalLinks else Check.All
case args' of
- Build _ -> Commands.build conf verbosity' rules
+ Build _ -> Commands.build conf verbosity' rules >>= exitWith
Check _ _ -> Commands.check conf verbosity' check'
Clean _ -> Commands.clean conf
- Deploy _ -> Commands.deploy conf
+ Deploy _ -> Commands.deploy conf >>= exitWith
Help _ -> showHelp
Preview _ p -> Commands.preview conf verbosity' rules p
- Rebuild _ -> Commands.rebuild conf verbosity' rules
+ Rebuild _ -> Commands.rebuild conf verbosity' rules >>= exitWith
Server _ _ -> Commands.server conf (port args')