diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-17 09:13:49 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-04-17 09:13:49 +0200 |
commit | c7be8f4fc6e50fd81207c2feba49263cef457533 (patch) | |
tree | 71e4419ed302dc54a646fa99ed39b4d3df41b96b | |
parent | 3a78c2be92cfd5d60c3b03350271a693cdbc96ea (diff) | |
download | hakyll-c7be8f4fc6e50fd81207c2feba49263cef457533.tar.gz |
Dump dependency cycle on error
-rw-r--r-- | src/Hakyll/Core/DependencyAnalyzer.hs | 1 | ||||
-rw-r--r-- | src/Hakyll/Core/Run.hs | 13 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Hakyll/Core/DependencyAnalyzer.hs b/src/Hakyll/Core/DependencyAnalyzer.hs index 2f13b37..c39b399 100644 --- a/src/Hakyll/Core/DependencyAnalyzer.hs +++ b/src/Hakyll/Core/DependencyAnalyzer.hs @@ -48,6 +48,7 @@ data DependencyAnalyzer a = DependencyAnalyzer data Signal a = Build a | Cycle [a] | Done + deriving (Show) instance (Ord a, Show a) => Monoid (DependencyAnalyzer a) where mempty = DependencyAnalyzer mempty mempty mempty mempty diff --git a/src/Hakyll/Core/Run.hs b/src/Hakyll/Core/Run.hs index b076cb0..e2cab3c 100644 --- a/src/Hakyll/Core/Run.hs +++ b/src/Hakyll/Core/Run.hs @@ -6,7 +6,7 @@ module Hakyll.Core.Run ) where import Prelude hiding (reverse) -import Control.Monad (filterM) +import Control.Monad (filterM, forM_) import Control.Monad.Trans (liftIO) import Control.Applicative (Applicative, (<$>)) import Control.Monad.Reader (ReaderT, runReaderT, ask) @@ -147,9 +147,18 @@ stepAnalyzer = Runtime $ do put $ state { hakyllAnalyzer = analyzer' } case signal of Done -> return () - Cycle _ -> return () + Cycle c -> unRuntime $ dumpCycle c Build id' -> unRuntime $ build id' +-- | Dump cyclic error and quit +-- +dumpCycle :: [Identifier] -> Runtime () +dumpCycle cycle' = Runtime $ do + logger <- hakyllLogger <$> ask + section logger "Dependency cycle detected! Conflict:" + forM_ (zip cycle' $ drop 1 cycle') $ \(x, y) -> + report logger $ show x ++ " -> " ++ show y + build :: Identifier -> Runtime () build id' = Runtime $ do logger <- hakyllLogger <$> ask |