Commit a7298b6f4d3356e2209af616a14cabf1dccf8536 Parent: 11056c3d0fbf90b11741965912e9724e78352615 Author: mcol <mcol@posteo.net> Date: 2022-05-14 19:26:08 +0100 Committer: mcol <mcol@posteo.net> Committed: 2022-05-14 19:26:08 +0100 neaten up some cases
src/Repositories.hs Modified
@@ -1,3 +1,4 @@ +{-# LANGUAGE BlockArguments #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} @@ -11,7 +12,7 @@ import Conduit (runConduit, sinkList, (.|)) import Control.Exception (try) import Control.Monad (filterM, unless, when, (<=<)) -import Control.Monad.Extra (ifM) +import Control.Monad.Extra (ifM, whenJust) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Reader (ReaderT) import Data.Bool (bool) @@ -151,19 +152,13 @@ ReaderT LgRepo IO () gen = genTarget scope quiet force - case envCommitTemplate env of - Just commitT -> do - let category = T.pack "commit" - output' <- liftIO . fmap (output </>) . parseRelDir $ "commit" - mapM_ (gen commitT category output' commitHref) commits - Nothing -> return () - - case envFileTemplate env of - Just fileT -> do - let category = T.pack "file" - output' <- liftIO . fmap (output </>) . parseRelDir $ "file" - mapM_ (gen fileT category output' fileHref) tree -- TODO: detect file changes - Nothing -> return () + whenJust (envCommitTemplate env) \commitT -> do + output' <- liftIO . fmap (output </>) . parseRelDir $ "commit" + mapM_ (gen commitT "commit" output' commitHref) commits + + whenJust (envFileTemplate env) \fileT -> do + output' <- liftIO . fmap (output </>) . parseRelDir $ "file" + mapM_ (gen fileT "file" output' fileHref) tree -- TODO: detect file changes -- Copy any static files/folders into the output folder -- liftIO . envRepoCopyStatics env $ output