diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CheckDir.hs | 13 | ||||
-rw-r--r-- | lib/CheckMap.hs | 2 | ||||
-rw-r--r-- | lib/WriteRepo.hs | 28 |
3 files changed, 33 insertions, 10 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs index 4654051..68bcefe 100644 --- a/lib/CheckDir.hs +++ b/lib/CheckDir.hs @@ -6,17 +6,17 @@ {-# LANGUAGE TupleSections #-} -- | Module that contains high-level checking for an entire directory -module CheckDir (recursiveCheckDir, writeAdjustedRepository) where +module CheckDir (recursiveCheckDir, DirResult(..)) where -import CheckMap (MapResult (mapresultAdjusted, mapresultProvides), +import CheckMap (MapResult (mapresultProvides), loadAndLintMap, mapresultDepends) import Control.Monad (void) import Control.Monad.Extra (mapMaybeM) -import Data.Aeson (ToJSON, encodeFile, (.=)) +import Data.Aeson (ToJSON, (.=)) import qualified Data.Aeson as A import Data.Foldable (fold) import Data.Functor ((<&>)) -import Data.Map (Map, toList) +import Data.Map (Map) import qualified Data.Map as M import Data.Map.Strict (mapKeys, (\\)) import Data.Maybe (mapMaybe) @@ -206,8 +206,3 @@ recursiveCheckDir' prefix paths done acc = do -writeAdjustedRepository :: FilePath -> DirResult -> IO () -writeAdjustedRepository outPath result = - mapM_ - (\(path,out) -> encodeFile (outPath </> path) $ mapresultAdjusted out) - (toList $ dirresultMaps result) diff --git a/lib/CheckMap.hs b/lib/CheckMap.hs index 41f251e..1b42854 100644 --- a/lib/CheckMap.hs +++ b/lib/CheckMap.hs @@ -11,6 +11,7 @@ module CheckMap (loadAndLintMap, MapResult(..)) where import Data.Aeson (ToJSON (toJSON)) import qualified Data.Aeson as A import Data.Aeson.Types ((.=)) +import Data.Functor ((<&>)) import Data.Map (Map, toList) import qualified Data.Map as M import Data.Maybe (mapMaybe) @@ -20,7 +21,6 @@ import qualified Data.Vector as V import GHC.Generics (Generic) -import Data.Functor ((<&>)) import LintWriter (filterLintLevel, invertLintResult, lintToDep, resultToAdjusted, resultToDeps, resultToLints, resultToOffers, runLintWriter) 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 |