Commit 247e0c2f4562522a52dc00203be5c2b109c07ec9 Parent: f0cd4e9c4d7073b9d48ad452c8bb4edf0ecddf66 Author: mcol <mcol@posteo.net> Date: 2021-12-04 13:10:42 +0300 Committer: mcol <mcol@posteo.net> Committed: 2021-12-04 13:10:42 +0300 Exit early with message if no templates are found Closes #22
src/Templates.hs Modified
@@ -14,7 +14,7 @@ import Control.Monad.Trans.Reader (ReaderT) import qualified Data.HashMap.Strict as HashMap import Data.IORef (modifyIORef', newIORef, readIORef) -import Data.Maybe (catMaybes, fromMaybe) +import Data.Maybe (catMaybes, fromMaybe, isNothing) import qualified Data.Text as T import qualified Data.Text.Lazy.Builder as TB import qualified Data.Text.Lazy.IO as T @@ -38,6 +38,7 @@ pathIsSymbolicLink, removeFile, ) +import System.Exit (die) import qualified System.FilePath as FP import System.IO.Error (tryIOError) import qualified Text.Ginger.AST as G @@ -104,6 +105,15 @@ . filter (flip notElem ["commit.html", "file.html"] . toFilePath . filename) $ filesRepo + -- Exit early if we didn't find any templates + when + ( null indexT + && isNothing commitT + && isNothing fileT + && null repoT + ) + $ die "No templates were found." + -- App environment return Env