Filter files in withArbitraryFilesProjectVisitor

This commit is contained in:
Jeroen Engels 2023-06-02 16:26:06 +02:00
parent 082c6cee77
commit 2af4f864cf

View File

@ -1868,11 +1868,17 @@ withArbitraryFilesProjectVisitor :
-> (List { path : String, content : String } -> projectContext -> ( List (Error { useErrorForModule : () }), projectContext ))
-> ProjectRuleSchema schemaState projectContext moduleContext
-> ProjectRuleSchema { schemaState | hasAtLeastOneVisitor : () } projectContext moduleContext
withArbitraryFilesProjectVisitor newRequestedFiles visitor (ProjectRuleSchema schema) =
withArbitraryFilesProjectVisitor requestedFiles baseVisitor (ProjectRuleSchema schema) =
let
visitor : List { path : String, content : String } -> projectContext -> ( List (Error {}), projectContext )
visitor files context =
baseVisitor (List.filter (globMatch requestedFiles) files) context
|> Tuple.mapFirst removeErrorPhantomTypes
in
ProjectRuleSchema
{ schema
| arbitraryFilesVisitor = Just (combineVisitors (removeErrorPhantomTypeFromVisitor visitor) schema.arbitraryFilesVisitor)
, arbitraryFileRequest = newRequestedFiles ++ schema.arbitraryFileRequest
| arbitraryFilesVisitor = Just (combineVisitors visitor schema.arbitraryFilesVisitor)
, arbitraryFileRequest = requestedFiles ++ schema.arbitraryFileRequest
}