diff options
author | stuebinm | 2021-11-10 22:49:17 +0100 |
---|---|---|
committer | stuebinm | 2021-11-10 22:49:17 +0100 |
commit | 508f8885f6087f2c56b188cd0632a4fc39de0540 (patch) | |
tree | 95c8036e1d73ee2a0b20ef76d892d83927fd6243 /lib/WriteRepo.hs | |
parent | 5bb4079f7b2d576f67649c37874556e73dc8f68b (diff) |
extra module for repository writeout
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 |