summaryrefslogtreecommitdiff
path: root/lib/WriteRepo.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WriteRepo.hs')
-rw-r--r--lib/WriteRepo.hs28
1 files changed, 28 insertions, 0 deletions
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