summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CheckDir.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/CheckDir.hs b/lib/CheckDir.hs
index 7a1629f..7b5e46d 100644
--- a/lib/CheckDir.hs
+++ b/lib/CheckDir.hs
@@ -19,8 +19,8 @@ import Data.Functor ((<&>))
import Data.Map (Map, elems, keys)
import qualified Data.Map as M
import Data.Map.Strict (mapKeys, mapWithKey, (\\))
-import Data.Maybe (mapMaybe)
-import Data.Text (Text)
+import Data.Maybe (mapMaybe, isJust)
+import Data.Text (Text, isInfixOf)
import qualified Data.Text as T
import Dirgraph (graphToDot, invertGraph, resultToGraph,
unreachableFrom)
@@ -57,7 +57,8 @@ data DirResult = DirResult
} deriving (Generic)
data MissingDep = MissingDep
- { entrypoint :: Text
+ { depFatal :: Maybe Bool
+ , entrypoint :: Text
, neededBy :: [FilePath]
} deriving (Generic, ToJSON)
@@ -69,7 +70,7 @@ newtype MissingAsset = MissingAsset MissingDep
-- | given this config, should the result be considered to have failed?
resultIsFatal :: LintConfig' -> DirResult -> Bool
resultIsFatal config res =
- not (null $ dirresultMissingAssets res)
+ not (null (dirresultMissingAssets res) || not (any (isJust . depFatal) (dirresultDeps res)))
|| maximumLintLevel res > configMaxLintLevel config
-- | maximum lint level that was observed anywhere in any map.
@@ -124,7 +125,7 @@ instance PrettyPrint (Level, DirResult) where
"\nin " <> T.pack p <> ":\n" <> prettyprint (level, lint)
instance PrettyPrint MissingDep where
- prettyprint (MissingDep f n) =
+ prettyprint (MissingDep _ f n) =
" - " <> f <> " does not exist, but is required by "
<> prettyDependents <> "\n"
where
@@ -172,7 +173,7 @@ recursiveCheckDir config prefix root = do
missingDeps :: FilePath -> Map FilePath MapResult -> [MissingDep]
missingDeps entrypoint maps =
let simple = M.insert (T.pack entrypoint) [] used \\ M.union defined trivial
- in M.foldMapWithKey (\f n -> [MissingDep f n]) simple
+ in M.foldMapWithKey (\f n -> [MissingDep (Just $ not ("#" `isInfixOf` f)) f n]) simple
where
-- which maps are linked somewhere?
used :: Map Text [FilePath]
@@ -201,7 +202,7 @@ missingAssets prefix maps =
let asset = normalise (takeDirectory path) relpath
in doesFileExist (prefix </> asset) <&>
\case True -> Nothing
- False -> Just $ MissingDep (T.pack asset) [path]
+ False -> Just $ MissingDep Nothing (T.pack asset) [path]
_ -> pure Nothing)
(mapresultDepends mapres)