mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-09-11 16:16:09 +03:00
Move makePathOSAgnostic to a separate module
This commit is contained in:
parent
5395f1b934
commit
5219ef4a03
6
src/Path.elm
Normal file
6
src/Path.elm
Normal file
@ -0,0 +1,6 @@
|
||||
module Path exposing (makeOSAgnostic)
|
||||
|
||||
|
||||
makeOSAgnostic : String -> String
|
||||
makeOSAgnostic path =
|
||||
String.replace "\\" "/" path
|
@ -16,6 +16,7 @@ module Review.Exceptions exposing
|
||||
|
||||
-}
|
||||
|
||||
import Path
|
||||
import Set exposing (Set)
|
||||
|
||||
|
||||
@ -40,7 +41,7 @@ addDirectories directories =
|
||||
cleanedDirectories =
|
||||
directories
|
||||
|> List.map
|
||||
(makePathOSAgnostic
|
||||
(Path.makeOSAgnostic
|
||||
>> (\dir ->
|
||||
if String.endsWith "/" dir then
|
||||
dir
|
||||
@ -59,7 +60,7 @@ addFiles files =
|
||||
cleanedFiles : Set String
|
||||
cleanedFiles =
|
||||
files
|
||||
|> List.map makePathOSAgnostic
|
||||
|> List.map Path.makeOSAgnostic
|
||||
|> Set.fromList
|
||||
in
|
||||
addFilter (\file -> Set.member file cleanedFiles |> not)
|
||||
@ -73,15 +74,10 @@ isFileWeWantReportsFor (Exceptions conditions) filePath =
|
||||
List.all (\condition -> condition path) conditions
|
||||
in
|
||||
filePath
|
||||
|> makePathOSAgnostic
|
||||
|> Path.makeOSAgnostic
|
||||
|> allConditions
|
||||
|
||||
|
||||
isInAnIgnoredDirectory : List String -> String -> Bool
|
||||
isInAnIgnoredDirectory directories path =
|
||||
List.any (\dir -> String.startsWith dir path) directories
|
||||
|
||||
|
||||
makePathOSAgnostic : String -> String
|
||||
makePathOSAgnostic path =
|
||||
String.replace "\\" "/" path
|
||||
|
@ -47,6 +47,7 @@ import Elm.Project
|
||||
import Elm.Syntax.File
|
||||
import Elm.Syntax.ModuleName exposing (ModuleName)
|
||||
import Elm.Syntax.Node as Node
|
||||
import Path
|
||||
import Review.FileParser as FileParser
|
||||
import Review.Project.Dependency as Dependency exposing (Dependency)
|
||||
import Review.Project.Internal as Internal exposing (Project)
|
||||
@ -113,14 +114,14 @@ addModule { path, source } project =
|
||||
let
|
||||
osAgnosticPath : String
|
||||
osAgnosticPath =
|
||||
makePathOSAgnostic path
|
||||
Path.makeOSAgnostic path
|
||||
in
|
||||
project
|
||||
|> addModuleToProject
|
||||
{ path = path
|
||||
, source = source
|
||||
, ast = ast
|
||||
, isInSourceDirectories = List.any (\dir -> String.startsWith (makePathOSAgnostic dir) osAgnosticPath) (Internal.sourceDirectories project)
|
||||
, isInSourceDirectories = List.any (\dir -> String.startsWith (Path.makeOSAgnostic dir) osAgnosticPath) (Internal.sourceDirectories project)
|
||||
}
|
||||
|> removeFileFromFilesThatFailedToParse path
|
||||
|> forceModuleGraphRecomputation
|
||||
@ -150,7 +151,7 @@ addParsedModule { path, source, ast } project =
|
||||
let
|
||||
osAgnosticPath : String
|
||||
osAgnosticPath =
|
||||
makePathOSAgnostic path
|
||||
Path.makeOSAgnostic path
|
||||
in
|
||||
project
|
||||
|> removeFileFromFilesThatFailedToParse path
|
||||
@ -158,7 +159,7 @@ addParsedModule { path, source, ast } project =
|
||||
{ path = path
|
||||
, source = source
|
||||
, ast = ast
|
||||
, isInSourceDirectories = List.any (\dir -> String.startsWith (makePathOSAgnostic dir) osAgnosticPath) (Internal.sourceDirectories project)
|
||||
, isInSourceDirectories = List.any (\dir -> String.startsWith (Path.makeOSAgnostic dir) osAgnosticPath) (Internal.sourceDirectories project)
|
||||
}
|
||||
|> forceModuleGraphRecomputation
|
||||
|
||||
@ -279,7 +280,7 @@ addElmJson elmJson_ (Internal.Project project) =
|
||||
let
|
||||
osAgnosticPath : String
|
||||
osAgnosticPath =
|
||||
makePathOSAgnostic value.path
|
||||
Path.makeOSAgnostic value.path
|
||||
in
|
||||
{ value | isInSourceDirectories = List.any (\dir -> String.startsWith dir osAgnosticPath) sourceDirectories }
|
||||
)
|
||||
@ -297,7 +298,7 @@ sourceDirectoriesForProject : Elm.Project.Project -> List String
|
||||
sourceDirectoriesForProject elmJson_ =
|
||||
case elmJson_ of
|
||||
Elm.Project.Application { dirs } ->
|
||||
List.map (removeDotSlashAtBeginning >> makePathOSAgnostic >> endWithSlash) dirs
|
||||
List.map (removeDotSlashAtBeginning >> Path.makeOSAgnostic >> endWithSlash) dirs
|
||||
|
||||
Elm.Project.Package _ ->
|
||||
[ "src/" ]
|
||||
@ -426,11 +427,6 @@ directDependencies (Internal.Project project) =
|
||||
project.dependencies
|
||||
|
||||
|
||||
makePathOSAgnostic : String -> String
|
||||
makePathOSAgnostic path =
|
||||
String.replace "\\" "/" path
|
||||
|
||||
|
||||
|
||||
-- GRAPH CREATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user