on master help sign in
Allow overriding the `deploy` command with Haskell code
543cba9Samuel Tardieu
src/Hakyll/Commands.hs+1−4
@@ -14,7 +14,6 @@ module Hakyll.Commands
14
14
15--------------------------------------------------------------------------------
15--------------------------------------------------------------------------------
16import System.Exit (ExitCode (ExitSuccess), exitWith)
16import System.Exit (ExitCode (ExitSuccess), exitWith)
17−import System.Process (system)
18
17
19
18
20--------------------------------------------------------------------------------
19--------------------------------------------------------------------------------
@@ -109,9 +108,7 @@ server _ _ = previewServerDisabled
109--------------------------------------------------------------------------------
108--------------------------------------------------------------------------------
110-- | Upload the site
109-- | Upload the site
111deploy :: Configuration -> IO ()
110deploy :: Configuration -> IO ()
112−deploy conf = do
111+deploy conf = deploySite conf conf
113− _ <- system $ deployCommand conf
114− return ()
115
112
116
113
117--------------------------------------------------------------------------------
114--------------------------------------------------------------------------------
src/Hakyll/Core/Configuration.hs+13
@@ -8,9 +8,11 @@ module Hakyll.Core.Configuration
8
8
9
9
10--------------------------------------------------------------------------------
10--------------------------------------------------------------------------------
11+import Control.Monad (void)
11import Data.Default (Default(..))
12import Data.Default (Default(..))
12import Data.List (isPrefixOf, isSuffixOf)
13import Data.List (isPrefixOf, isSuffixOf)
13import System.FilePath (normalise, takeFileName)
14import System.FilePath (normalise, takeFileName)
15+import System.Process (system)
14
16
15
17
16--------------------------------------------------------------------------------
18--------------------------------------------------------------------------------
@@ -52,6 +54,16 @@ data Configuration = Configuration
52 -- > ./site deploy
54 -- > ./site deploy
53 --
55 --
54 deployCommand :: String
56 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 ()
55 , -- | Use an in-memory cache for items. This is faster but uses more
67 , -- | Use an in-memory cache for items. This is faster but uses more
56 -- memory.
68 -- memory.
57 inMemoryCache :: Bool
69 inMemoryCache :: Bool
@@ -71,6 +83,7 @@ defaultConfiguration = Configuration
71 , providerDirectory = "."
83 , providerDirectory = "."
72 , ignoreFile = ignoreFile'
84 , ignoreFile = ignoreFile'
73 , deployCommand = "echo 'No deploy command specified'"
85 , deployCommand = "echo 'No deploy command specified'"
86+ , deploySite = void . system . deployCommand
74 , inMemoryCache = True
87 , inMemoryCache = True
75 }
88 }
76 where
89 where