summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Hakyll/Check.hs14
-rw-r--r--src/Hakyll/Commands.hs28
-rw-r--r--src/Hakyll/Core/Configuration.hs10
-rw-r--r--src/Hakyll/Core/Runtime.hs8
-rw-r--r--src/Hakyll/Main.hs21
-rw-r--r--tests/Hakyll/Core/Runtime/Tests.hs3
-rw-r--r--tests/TestSuite/Util.hs1
7 files changed, 37 insertions, 48 deletions
diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs
index 232d510..5908310 100644
--- a/src/Hakyll/Check.hs
+++ b/src/Hakyll/Check.hs
@@ -30,16 +30,16 @@ import qualified Text.HTML.TagSoup as TS
--------------------------------------------------------------------------------
import Hakyll.Core.Configuration
-import Hakyll.Core.Logger (Logger)
+import Hakyll.Core.Logger (Logger, Verbosity)
import qualified Hakyll.Core.Logger as Logger
import Hakyll.Core.Util.File
import Hakyll.Web.Html
--------------------------------------------------------------------------------
-check :: Configuration -> IO ExitCode
-check config = do
- ((), write) <- runChecker checkDestination config
+check :: Configuration -> Verbosity -> IO ExitCode
+check config verbosity = do
+ ((), write) <- runChecker checkDestination config verbosity
return $ if checkerFaulty write >= 0 then ExitFailure 1 else ExitSuccess
@@ -73,9 +73,9 @@ type Checker a = RWST CheckerRead CheckerWrite CheckerState IO a
--------------------------------------------------------------------------------
-runChecker :: Checker a -> Configuration -> IO (a, CheckerWrite)
-runChecker checker config = do
- logger <- Logger.new (verbosity config)
+runChecker :: Checker a -> Configuration -> Verbosity -> IO (a, CheckerWrite)
+runChecker checker config verbosity = do
+ logger <- Logger.new verbosity
let read' = CheckerRead config logger
(x, _, write) <- runRWST checker read' S.empty
Logger.flush logger
diff --git a/src/Hakyll/Commands.hs b/src/Hakyll/Commands.hs
index 88905ea..23deb7f 100644
--- a/src/Hakyll/Commands.hs
+++ b/src/Hakyll/Commands.hs
@@ -23,13 +23,13 @@ import System.Process (system)
--------------------------------------------------------------------------------
import qualified Hakyll.Check as Check
import Hakyll.Core.Configuration
+import Hakyll.Core.Logger (Verbosity)
import Hakyll.Core.Rules
import Hakyll.Core.Runtime
--------------------------------------------------------------------------------
#ifdef PREVIEW_SERVER
-import Control.Applicative ((<$>))
import Control.Concurrent (forkIO)
import qualified Data.Set as S
import Hakyll.Core.Identifier
@@ -41,16 +41,16 @@ import Hakyll.Preview.Server
--------------------------------------------------------------------------------
-- | Build the site
-build :: Configuration -> Rules a -> IO ()
-build conf rules = do
- _ <- run conf rules
+build :: Configuration -> Verbosity -> Rules a -> IO ()
+build conf verbosity rules = do
+ _ <- run conf verbosity rules
return ()
--------------------------------------------------------------------------------
-- | Run the checker and exit
-check :: Configuration -> IO ()
-check config = Check.check config >>= exitWith
+check :: Configuration -> Verbosity -> IO ()
+check config verbosity = Check.check config verbosity >>= exitWith
--------------------------------------------------------------------------------
@@ -68,27 +68,29 @@ clean conf = do
--------------------------------------------------------------------------------
-- | Preview the site
-preview :: Configuration -> Rules a -> Int -> IO ()
+preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()
#ifdef PREVIEW_SERVER
-preview conf rules port = do
+preview conf verbosity rules port = do
-- Fork a thread polling for changes
_ <- forkIO $ previewPoll conf update
-- Run the server in the main thread
server conf port
where
- update = map toFilePath . S.toList . rulesResources <$> run conf rules
+ update = do
+ ruleSet <- run conf verbosity rules
+ return $ map toFilePath $ S.toList $ rulesResources ruleSet
#else
-preview _ _ _ = previewServerDisabled
+preview _ _ _ _ = previewServerDisabled
#endif
--------------------------------------------------------------------------------
-- | Rebuild the site
-rebuild :: Configuration -> Rules a -> IO ()
-rebuild conf rules = do
+rebuild :: Configuration -> Verbosity -> Rules a -> IO ()
+rebuild conf verbosity rules = do
clean conf
- build conf rules
+ build conf verbosity rules
--------------------------------------------------------------------------------
diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs
index c45d1a3..86898dc 100644
--- a/src/Hakyll/Core/Configuration.hs
+++ b/src/Hakyll/Core/Configuration.hs
@@ -1,8 +1,7 @@
--------------------------------------------------------------------------------
-- | Exports a datastructure for the top-level hakyll configuration
module Hakyll.Core.Configuration
- ( Verbosity (..)
- , Configuration (..)
+ ( Configuration (..)
, shouldIgnoreFile
, defaultConfiguration
) where
@@ -14,10 +13,6 @@ import System.FilePath (normalise, takeFileName)
--------------------------------------------------------------------------------
-import Hakyll.Core.Logger
-
-
---------------------------------------------------------------------------------
data Configuration = Configuration
{ -- | Directory in which the output written
destinationDirectory :: FilePath
@@ -57,8 +52,6 @@ data Configuration = Configuration
, -- | Use an in-memory cache for items. This is faster but uses more
-- memory.
inMemoryCache :: Bool
- -- | Verbosity for the logger. Can be overwritten by the command-line.
- , verbosity :: Verbosity
}
@@ -72,7 +65,6 @@ defaultConfiguration = Configuration
, ignoreFile = ignoreFile'
, deployCommand = "echo 'No deploy command specified'"
, inMemoryCache = True
- , verbosity = Message
}
where
ignoreFile' path
diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs
index 7e4a835..e052f37 100644
--- a/src/Hakyll/Core/Runtime.hs
+++ b/src/Hakyll/Core/Runtime.hs
@@ -28,7 +28,7 @@ import Hakyll.Core.Configuration
import Hakyll.Core.Dependencies
import Hakyll.Core.Identifier
import Hakyll.Core.Item.SomeItem
-import Hakyll.Core.Logger (Logger)
+import Hakyll.Core.Logger (Logger, Verbosity)
import qualified Hakyll.Core.Logger as Logger
import Hakyll.Core.Provider
import Hakyll.Core.Routes
@@ -41,10 +41,10 @@ import Hakyll.Core.Writable
--------------------------------------------------------------------------------
-- | TODO Make this return exit code?
-run :: Configuration -> Rules a -> IO RuleSet
-run config rules = do
+run :: Configuration -> Verbosity -> Rules a -> IO RuleSet
+run config verbosity rules = do
-- Initialization
- logger <- Logger.new (verbosity config)
+ logger <- Logger.new verbosity
Logger.header logger "Initialising..."
Logger.message logger "Creating store..."
store <- Store.new (inMemoryCache config) $ storeDirectory config
diff --git a/src/Hakyll/Main.hs b/src/Hakyll/Main.hs
index e7f10ab..86aae28 100644
--- a/src/Hakyll/Main.hs
+++ b/src/Hakyll/Main.hs
@@ -35,21 +35,16 @@ hakyllWith :: Config.Configuration -> Rules a -> IO ()
hakyllWith conf rules = do
args' <- cmdArgs hakyllArgs
- -- Overwrite conf based on args
- let conf' = conf
- { Config.verbosity =
- if verbose args' then Logger.Debug else Config.verbosity conf
- }
-
+ let verbosity' = if verbose args' then Logger.Debug else Logger.Message
case args' of
- Build _ -> Commands.build conf' rules
- Check _ -> Commands.check conf'
- Clean _ -> Commands.clean conf'
- Deploy _ -> Commands.deploy conf'
+ Build _ -> Commands.build conf verbosity' rules
+ Check _ -> Commands.check conf verbosity'
+ Clean _ -> Commands.clean conf
+ Deploy _ -> Commands.deploy conf
Help _ -> showHelp
- Preview _ p -> Commands.preview conf' rules p
- Rebuild _ -> Commands.rebuild conf' rules
- Server _ _ -> Commands.server conf' (port args')
+ Preview _ p -> Commands.preview conf verbosity' rules p
+ Rebuild _ -> Commands.rebuild conf verbosity' rules
+ Server _ _ -> Commands.server conf (port args')
--------------------------------------------------------------------------------
diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs
index af85f4f..fa1446f 100644
--- a/tests/Hakyll/Core/Runtime/Tests.hs
+++ b/tests/Hakyll/Core/Runtime/Tests.hs
@@ -13,6 +13,7 @@ import Test.HUnit (Assertion, (@?=))
--------------------------------------------------------------------------------
import Hakyll
+import qualified Hakyll.Core.Logger as Logger
import Hakyll.Core.Runtime
import TestSuite.Util
@@ -25,7 +26,7 @@ tests = testGroup "Hakyll.Core.Runtime.Tests" $ fromAssertions "run" [case01]
--------------------------------------------------------------------------------
case01 :: Assertion
case01 = withTestConfiguration $ \config -> do
- _ <- run config $ do
+ _ <- run config Logger.Error $ do
match "*.md" $ do
route $ setExtension "html"
compile $ do
diff --git a/tests/TestSuite/Util.hs b/tests/TestSuite/Util.hs
index 7000f5d..91f4339 100644
--- a/tests/TestSuite/Util.hs
+++ b/tests/TestSuite/Util.hs
@@ -110,5 +110,4 @@ withTestConfiguration f = do
{ destinationDirectory = "_testsite"
, storeDirectory = "_teststore"
, providerDirectory = "tests/data"
- , verbosity = Logger.Error
}