diff options
Diffstat (limited to '')
-rw-r--r-- | lib/WriteRepo.hs | 28 |
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 |