on master help sign in
Dump dependency cycle on error
c7be8f4Jasper Van der Jeugt
src/Hakyll/Core/DependencyAnalyzer.hs+1
@@ -48,6 +48,7 @@ data DependencyAnalyzer a = DependencyAnalyzer
48data Signal a = Build a
48data Signal a = Build a
49 | Cycle [a]
49 | Cycle [a]
50 | Done
50 | Done
51+ deriving (Show)
51
52
52instance (Ord a, Show a) => Monoid (DependencyAnalyzer a) where
53instance (Ord a, Show a) => Monoid (DependencyAnalyzer a) where
53 mempty = DependencyAnalyzer mempty mempty mempty mempty
54 mempty = DependencyAnalyzer mempty mempty mempty mempty
src/Hakyll/Core/Run.hs+11−2
@@ -6,7 +6,7 @@ module Hakyll.Core.Run
6 ) where
6 ) where
7
7
8import Prelude hiding (reverse)
8import Prelude hiding (reverse)
9−import Control.Monad (filterM)
9+import Control.Monad (filterM, forM_)
10import Control.Monad.Trans (liftIO)
10import Control.Monad.Trans (liftIO)
11import Control.Applicative (Applicative, (<$>))
11import Control.Applicative (Applicative, (<$>))
12import Control.Monad.Reader (ReaderT, runReaderT, ask)
12import Control.Monad.Reader (ReaderT, runReaderT, ask)
@@ -147,9 +147,18 @@ stepAnalyzer = Runtime $ do
147 put $ state { hakyllAnalyzer = analyzer' }
147 put $ state { hakyllAnalyzer = analyzer' }
148
148
149 case signal of Done -> return ()
149 case signal of Done -> return ()
150− Cycle _ -> return ()
150+ Cycle c -> unRuntime $ dumpCycle c
151 Build id' -> unRuntime $ build id'
151 Build id' -> unRuntime $ build id'
152
152
153+-- | Dump cyclic error and quit
154+--
155+dumpCycle :: [Identifier] -> Runtime ()
156+dumpCycle cycle' = Runtime $ do
157+ logger <- hakyllLogger <$> ask
158+ section logger "Dependency cycle detected! Conflict:"
159+ forM_ (zip cycle' $ drop 1 cycle') $ \(x, y) ->
160+ report logger $ show x ++ " -> " ++ show y
161+
153build :: Identifier -> Runtime ()
162build :: Identifier -> Runtime ()
154build id' = Runtime $ do
163build id' = Runtime $ do
155 logger <- hakyllLogger <$> ask
164 logger <- hakyllLogger <$> ask