diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2013-03-24 21:47:05 +0100 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2013-03-24 21:52:21 +0100 |
commit | 543cba90f6efba8508d2feb3377b1a9f5f428c1a (patch) | |
tree | 747c32d1e0c267a1c074971bf5097eacced007a5 /src | |
parent | 6c8fda2c00bd14bf75c9fa1b98b09e283711a706 (diff) | |
download | hakyll-543cba90f6efba8508d2feb3377b1a9f5f428c1a.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Commands.hs | 5 | ||||
-rw-r--r-- | src/Hakyll/Core/Configuration.hs | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs index 4c60783..6e0b9f2 100644 --- a/src/Hakyll/Commands.hs +++ b/src/Hakyll/Commands.hs @@ -14,7 +14,6 @@ module Hakyll.Commands -------------------------------------------------------------------------------- import System.Exit (ExitCode (ExitSuccess), exitWith) -import System.Process (system) -------------------------------------------------------------------------------- @@ -109,9 +108,7 @@ server _ _ = previewServerDisabled -------------------------------------------------------------------------------- -- | Upload the site deploy :: Configuration -> IO () -deploy conf = do - _ <- system $ deployCommand conf - return () +deploy conf = deploySite conf conf -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index 5382b6d..480c6c4 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -8,9 +8,11 @@ module Hakyll.Core.Configuration -------------------------------------------------------------------------------- +import Control.Monad (void) import Data.Default (Default(..)) import Data.List (isPrefixOf, isSuffixOf) import System.FilePath (normalise, takeFileName) +import System.Process (system) -------------------------------------------------------------------------------- @@ -52,6 +54,16 @@ data Configuration = Configuration -- > ./site deploy -- deployCommand :: String + , -- | Function to deploy the site from Haskell. + -- + -- By default, this command executes the shell command stored in + -- 'deployCommand'. If you override it, 'deployCommand' will not + -- be used implicitely. + -- + -- The 'Configuration' object is passed as a parameter to this + -- function. + -- + deploySite :: Configuration -> IO () , -- | Use an in-memory cache for items. This is faster but uses more -- memory. inMemoryCache :: Bool @@ -71,6 +83,7 @@ defaultConfiguration = Configuration , providerDirectory = "." , ignoreFile = ignoreFile' , deployCommand = "echo 'No deploy command specified'" + , deploySite = void . system . deployCommand , inMemoryCache = True } where |