on master help sign in
Allow overriding the `deploy` command with Haskell code

By overriding `deploySite` with a `Configuration -> IO ()` code, the user can execute Haskell code to deploy the site rather than shell code. The default behaviour honors the `deployCommand` configuration field and is backward compatible.

commit543cba90f6efba8508d2feb3377b1a9f5f428c1a authorSamuel Tardieu <sam@rfc1149.net> dateSun 24 Mar 2013, 21:47 (14 years ago) parent6c8fda2
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