on master help sign in
Merge pull request #125 from samueltardieu/deploy-in-haskell

Allow overriding the `deploy` command with Haskell code

commite552896338fe369b363160111099af99b7f1d265 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 26 Mar 2013, 02:08 (14 years ago) parent6c8fda2543cba9
2 files changed+14−4
src/Hakyll/Commands.hs+1−4 src/Hakyll/Core/Configuration.hs+13
src/Hakyll/Commands.hs+1−4
@@ -14,7 +14,6 @@ module Hakyll.Commands
1414
1515--------------------------------------------------------------------------------
1616import System.Exit (ExitCode (ExitSuccess), exitWith)
17−import System.Process (system)
1817
1918
2019--------------------------------------------------------------------------------
@@ -109,9 +108,7 @@ server _ _ = previewServerDisabled
109108--------------------------------------------------------------------------------
110109-- | Upload the site
111110deploy :: Configuration -> IO ()
112−deploy conf = do
113− _ <- system $ deployCommand conf
114− return ()
111+deploy conf = deploySite conf conf
115112
116113
117114--------------------------------------------------------------------------------
src/Hakyll/Core/Configuration.hs+13
@@ -8,9 +8,11 @@ module Hakyll.Core.Configuration
88
99
1010--------------------------------------------------------------------------------
11+import Control.Monad (void)
1112import Data.Default (Default(..))
1213import Data.List (isPrefixOf, isSuffixOf)
1314import System.FilePath (normalise, takeFileName)
15+import System.Process (system)
1416
1517
1618--------------------------------------------------------------------------------
@@ -52,6 +54,16 @@ data Configuration = Configuration
5254 -- > ./site deploy
5355 --
5456 deployCommand :: String
57+ , -- | Function to deploy the site from Haskell.
58+ --
59+ -- By default, this command executes the shell command stored in
60+ -- 'deployCommand'. If you override it, 'deployCommand' will not
61+ -- be used implicitely.
62+ --
63+ -- The 'Configuration' object is passed as a parameter to this
64+ -- function.
65+ --
66+ deploySite :: Configuration -> IO ()
5567 , -- | Use an in-memory cache for items. This is faster but uses more
5668 -- memory.
5769 inMemoryCache :: Bool
@@ -71,6 +83,7 @@ defaultConfiguration = Configuration
7183 , providerDirectory = "."
7284 , ignoreFile = ignoreFile'
7385 , deployCommand = "echo 'No deploy command specified'"
86+ , deploySite = void . system . deployCommand
7487 , inMemoryCache = True
7588 }
7689 where