Skip to content
Snippets Groups Projects
Commit 0b29a7e8 authored by stuebinm's avatar stuebinm
Browse files

fail on missing map assets

(but not (yet?) on missing maps/entrypoints)
parent 1338e4a1
No related branches found
No related tags found
No related merge requests found
Pipeline #8289 failed
...@@ -16,15 +16,18 @@ import Data.Set (Set) ...@@ -16,15 +16,18 @@ import Data.Set (Set)
import qualified Data.Set as S import qualified Data.Set as S
import Paths (normalise) import Paths (normalise)
import System.Directory.Extra (copyFile, createDirectoryIfMissing) import System.Directory.Extra (copyFile, createDirectoryIfMissing)
import System.Exit (ExitCode (..))
import System.FilePath (takeDirectory) import System.FilePath (takeDirectory)
import qualified System.FilePath as FP import qualified System.FilePath as FP
import System.FilePath.Posix ((</>)) import System.FilePath.Posix ((</>))
import Types (Dep (Local)) import Types (Dep (Local))
writeAdjustedRepository :: FilePath -> FilePath -> DirResult -> IO () writeAdjustedRepository :: FilePath -> FilePath -> DirResult -> IO ExitCode
writeAdjustedRepository inPath outPath result writeAdjustedRepository inPath outPath result
| resultIsFatal result = pure () | resultIsFatal result = do
putStrLn "FATAL: Repository has missing assets; cannot write to outPath"
pure (ExitFailure 1)
| otherwise = do | otherwise = do
createDirectoryIfMissing True outPath createDirectoryIfMissing True outPath
...@@ -41,7 +44,7 @@ writeAdjustedRepository inPath outPath result ...@@ -41,7 +44,7 @@ writeAdjustedRepository inPath outPath result
let mapdir = takeDirectory mappath in let mapdir = takeDirectory mappath in
mapMaybe (\case mapMaybe (\case
Local path -> Just . normalise mapdir $ path Local path -> Just . normalise mapdir $ path
_ -> Nothing) _ -> Nothing)
$ mapresultDepends mapresult) $ mapresultDepends mapresult)
. toList $ dirresultMaps result . toList $ dirresultMaps result
...@@ -53,3 +56,5 @@ writeAdjustedRepository inPath outPath result ...@@ -53,3 +56,5 @@ writeAdjustedRepository inPath outPath result
in do in do
putStrLn $ "copying " <> assetPath <> " → " <> newPath putStrLn $ "copying " <> assetPath <> " → " <> newPath
copyFile assetPath newPath copyFile assetPath newPath
pure ExitSuccess
...@@ -17,6 +17,7 @@ import CheckDir (recursiveCheckDir) ...@@ -17,6 +17,7 @@ import CheckDir (recursiveCheckDir)
import WriteRepo (writeAdjustedRepository) import WriteRepo (writeAdjustedRepository)
import Types (Level (..)) import Types (Level (..))
import Util (printPretty) import Util (printPretty)
import System.Exit (exitWith)
-- | the options this cli tool can take -- | the options this cli tool can take
data Options = Options data Options = Options
...@@ -47,15 +48,16 @@ run options = do ...@@ -47,15 +48,16 @@ run options = do
lints <- recursiveCheckDir repo entry lints <- recursiveCheckDir repo entry
case out options of
Just outpath -> writeAdjustedRepository repo outpath lints
Nothing -> pure ()
if json options if json options
then printLB then printLB
$ if pretty options then encodePretty lints else encode lints $ if pretty options then encodePretty lints else encode lints
else printPretty (level, lints) else printPretty (level, lints)
case out options of
Just outpath -> writeAdjustedRepository repo outpath lints
>>= exitWith
Nothing -> pure ()
-- | haskell's many string types are FUN … -- | haskell's many string types are FUN …
printLB :: LB.ByteString -> IO () printLB :: LB.ByteString -> IO ()
printLB a = putStrLn $ C8.unpack $ LB.toStrict a printLB a = putStrLn $ C8.unpack $ LB.toStrict a
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment