summaryrefslogtreecommitdiff
path: root/lib/WriteRepo.hs
blob: 5e695f593f7ce0d1edd862485fff235d68a8452a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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