Skip to content

Commit

Permalink
Ignore node_modules when searching recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed Mar 21, 2017
1 parent 799e15e commit 021b55a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Syntax changes:
- End-of-line `--` comments are now kept on their original line when appropriate
- `--` comments in the middle of binary operator sequences no longer push the following expression to the next line
- `--` comments can be use to create sections in record expressions
- `elm-format --validate` (meant for use in CI scripts) now reports errors as JSON
- For Windows, CRLF newlines no longer corrupt literal strings

Bug fixes:
Expand All @@ -18,6 +17,10 @@ Bug fixes:
- Record expressions with a trailing comma are no longer allowed (and comments are now handled correctly)
- Block comments containing only multiple lines of whitespace no longer crash elm-format

Other changes:
- `elm-format --validate` (meant for use in CI scripts) now reports errors as JSON
- When recursively searching a directory, `node_modules` folders are ignored


## 0.5.2-alpha

Expand Down
23 changes: 17 additions & 6 deletions src/ElmFormat/Filesystem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@ fileList :: FileStore f => FilePath -> Free f [FilePath]
fileList =
let
children path =
if hasntFilename "elm-stuff" path then
if isSkippable path then
return []
else
do
directory <- doesDirectoryExist path
if directory then listDir path else return []
else
return []
in
collectFiles children


isSkippable :: FilePath -> Bool
isSkippable path =
or
[ hasFilename "elm-stuff" path
, hasFilename "node_modules" path
, hasFilename ".git" path
]

hasExtension :: String -> FilePath -> Bool
hasExtension ext path =
pack ext `isSuffixOf` pack path
Expand All @@ -52,6 +60,9 @@ findAllElmFiles inputFile =
filter (hasExtension ".elm") <$> fileList inputFile


hasntFilename :: String -> FilePath -> Bool
hasntFilename name path =
not (isSuffixOf (pack $ '/' : name) (pack path) || name == path)
hasFilename :: String -> FilePath -> Bool
hasFilename name path =
or
[ isSuffixOf (pack $ '/' : name) (pack path)
, name == path
]

0 comments on commit 021b55a

Please sign in to comment.