From 508f8885f6087f2c56b188cd0632a4fc39de0540 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Wed, 10 Nov 2021 22:49:17 +0100 Subject: extra module for repository writeout --- lib/WriteRepo.hs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/WriteRepo.hs (limited to 'lib/WriteRepo.hs') diff --git a/lib/WriteRepo.hs b/lib/WriteRepo.hs new file mode 100644 index 0000000..5e695f5 --- /dev/null +++ b/lib/WriteRepo.hs @@ -0,0 +1,28 @@ + + + +-- | Module for writing an already linted map Repository back out again. + +module WriteRepo where + +import CheckDir (DirResult (dirresultMaps)) +import CheckMap (MapResult (mapresultAdjusted)) +import Data.Aeson (encodeFile) +import Data.Map.Strict (toList) +import System.Directory.Extra (createDirectoryIfMissing) +import System.FilePath.Posix (()) + + + +writeAdjustedRepository :: FilePath -> DirResult -> IO () +writeAdjustedRepository outPath result = do + + -- True here just means the equivalent of mkdir -p + createDirectoryIfMissing True outPath + + -- write out all maps + mapM_ + (\(path,out) -> encodeFile (outPath path) $ mapresultAdjusted out) + (toList $ dirresultMaps result) + + -- TODO: copy all assets -- cgit v1.2.3