Skip to content

Commit 3f95f9d

Browse files
authored
Merge pull request #61 from hqm42/master
do not traverse ignored directories
2 parents 3326c80 + ba7f358 commit 3f95f9d

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

package.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ library:
5252
- blaze-html ==0.9.1.1
5353
- cmdargs ==0.10.20
5454
- directory ==1.3.1.5
55+
- extra ==1.6.13
5556
- megaparsec ==6.5.0
5657
- regex-posix ==0.95.2
5758
- servant ==0.14.1
@@ -83,6 +84,7 @@ executables:
8384
- blaze-html ==0.9.1.1
8485
- cmdargs ==0.10.20
8586
- directory ==1.3.1.5
87+
- extra ==1.6.13
8688
- megaparsec ==6.5.0
8789
- regex-posix ==0.95.2
8890
- servant ==0.14.1
@@ -114,6 +116,7 @@ tests:
114116
- blaze-html ==0.9.1.1
115117
- cmdargs ==0.10.20
116118
- directory ==1.3.1.5
119+
- extra ==1.6.13
117120
- megaparsec ==6.5.0
118121
- regex-posix ==0.95.2
119122
- servant ==0.14.1

src/Server.hs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ import qualified Data.Text as T
2626
import qualified Data.Yaml as Y
2727
import Servant
2828
import System.Directory
29-
import System.IO.HVFS
29+
import System.Directory.Extra
3030
import qualified System.IO.Strict as SIO
31-
import System.Path
3231
import System.Path.NameManip
3332
import Text.Blaze.Html5 (Html)
3433
import qualified Text.Blaze.Html5 as BZ
@@ -319,7 +318,7 @@ getAllFiles :: ToodlesConfig -> FilePath -> IO [SourceFile]
319318
getAllFiles (ToodlesConfig ignoredPaths _) basePath =
320319
E.catch
321320
(do putStrLn $ printf "Running toodles for path: %s" basePath
322-
files <- recurseDir SystemFS basePath
321+
files <- listFilesInside (return . not . ignorePath) basePath
323322
let validFiles = filter isValidFile files
324323
mapM
325324
(\f ->
@@ -333,20 +332,19 @@ getAllFiles (ToodlesConfig ignoredPaths _) basePath =
333332

334333
where
335334

336-
isValidFile :: FilePath -> Bool
337-
isValidFile path = fileHasValidExtension && not ignoreFile
335+
ignorePath :: FilePath -> Bool
336+
ignorePath path =
337+
let p = T.pack path
338+
in T.isInfixOf "node_modules" p || T.isSuffixOf "pb.go" p ||
339+
T.isSuffixOf "_pb2.py" p ||
340+
any (\r -> path =~ r :: Bool) ignoredPaths
338341

339-
where
342+
fileHasValidExtension :: FilePath -> Bool
343+
fileHasValidExtension path = any (\ext -> ext `T.isSuffixOf` T.pack path) (map extension fileTypeToComment)
340344

341-
fileHasValidExtension :: Bool
342-
fileHasValidExtension = any (\ext -> ext `T.isSuffixOf` T.pack path) (map extension fileTypeToComment)
345+
isValidFile :: FilePath -> Bool
346+
isValidFile path = (not $ ignorePath path) && fileHasValidExtension path
343347

344-
ignoreFile :: Bool
345-
ignoreFile =
346-
let p = T.pack path
347-
in T.isInfixOf "node_modules" p || T.isSuffixOf "pb.go" p ||
348-
T.isSuffixOf "_pb2.py" p ||
349-
any (\r -> path =~ r :: Bool) ignoredPaths
350348

351349
mapHead :: (a -> a) -> [a] -> [a]
352350
mapHead f (x:xs) = f x : xs

toodles.cabal

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.31.0.
3+
-- This file has been generated from package.yaml by hpack version 0.31.1.
44
--
55
-- see: https://github.com/sol/hpack
66
--
7-
-- hash: eca068224b8e938feec8b371e63c8819e81e6d2030806c1f220e08823596b7f7
7+
-- hash: 1b4520f165439b7fb3fce7f9d4d7a56afe20ac9ae86140d2b337e14f0517cbb6
88

99
name: toodles
1010
version: 1.0.2
@@ -56,6 +56,7 @@ library
5656
, blaze-html ==0.9.1.1
5757
, cmdargs ==0.10.20
5858
, directory ==1.3.1.5
59+
, extra ==1.6.13
5960
, hspec >=2.4.4
6061
, hspec-expectations >=0.8.2
6162
, megaparsec ==6.5.0
@@ -90,6 +91,7 @@ executable toodles
9091
, blaze-html ==0.9.1.1
9192
, cmdargs ==0.10.20
9293
, directory ==1.3.1.5
94+
, extra ==1.6.13
9395
, hspec >=2.4.4
9496
, hspec-expectations >=0.8.2
9597
, megaparsec ==6.5.0
@@ -125,6 +127,7 @@ test-suite toodles-test
125127
, blaze-html ==0.9.1.1
126128
, cmdargs ==0.10.20
127129
, directory ==1.3.1.5
130+
, extra ==1.6.13
128131
, hspec >=2.4.4
129132
, hspec-expectations >=0.8.2
130133
, megaparsec ==6.5.0

0 commit comments

Comments
 (0)