🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit 4e081e88d1349c88da3fb1cf62f973459502c54c
Parent: 168822c91572479a08800296ed22883032751002
Author: mcol <mcol@posteo.net>
Date: 2022-05-29 16:27:02 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2022-05-29 16:27:02 +0100

aggregate withRunInIO usages

src/Repositories.hs Modified

@@ -128,42 +128,41 @@
                 tree <- getTree gitHead
                 let scope = package env repos name (repositoryDescription repo) commits tree
 
-                -- Create the destination folders --
-                commitDir <- liftIO . parseRelDir $ "commit"
-                fileDir <- liftIO . parseRelDir $ "file"
-                liftIO . ensureDir $ output </> commitDir
-                liftIO . ensureDir $ output </> fileDir
-
-                -- Run the generator --
-                let quiet = envQuiet env
-                    force = envForce env
-
-                    -- This annotation blocks the first use of gen from making t concrete
-                    gen ::
-                        ToGVal RunRepo t =>
-                        (ReaderT LgRepo IO (GVal RunRepo) -> IO (GVal RunRepo)) ->
-                        Template ->
-                        T.Text ->
-                        Path Abs Dir ->
-                        (t -> FilePath) ->
-                        t ->
-                        IO ()
-                    gen = genTarget scope quiet force
-
-                withRunInIO \runInIO -> mapM_ (genRepo scope runInIO output) (envRepoTemplates env)
-
-                whenJust (envCommitTemplate env) \commitT ->
-                    withRunInIO \runInIO -> do
+                withRunInIO \runInIO -> do
+                    -- Create the destination folders --
+                    commitDir <- parseRelDir "commit"
+                    fileDir <- parseRelDir "file"
+                    ensureDir $ output </> commitDir
+                    ensureDir $ output </> fileDir
+
+                    -- Run the generator --
+                    let quiet = envQuiet env
+                        force = envForce env
+
+                        -- This annotation blocks the first use of gen from making t concrete
+                        gen ::
+                            ToGVal RunRepo t =>
+                            (ReaderT LgRepo IO (GVal RunRepo) -> IO (GVal RunRepo)) ->
+                            Template ->
+                            T.Text ->
+                            Path Abs Dir ->
+                            (t -> FilePath) ->
+                            t ->
+                            IO ()
+                        gen = genTarget scope quiet force
+
+                    mapM_ (genRepo scope runInIO output) (envRepoTemplates env)
+
+                    whenJust (envCommitTemplate env) \commitT -> do
                         output' <- fmap (output </>) . parseRelDir $ "commit"
                         mapM_ (gen runInIO commitT "commit" output' commitHref) commits
 
-                whenJust (envFileTemplate env) \fileT ->
-                    withRunInIO \runInIO -> do
+                    whenJust (envFileTemplate env) \fileT -> do
                         output' <- fmap (output </>) . parseRelDir $ "file"
                         mapM_ (gen runInIO fileT "file" output' fileHref) tree -- TODO: detect file changes
 
-                -- Copy any static files/folders into the output folder --
-                liftIO . envRepoCopyStatics env $ output
+                    -- Copy any static files/folders into the output folder --
+                    envRepoCopyStatics env output
 
             return
                 repo{repositoryHead = Just headCommit}