diff --git a/package.yaml b/package.yaml index c604774..6b70620 100644 --- a/package.yaml +++ b/package.yaml @@ -52,6 +52,7 @@ library: - blaze-html ==0.9.1.1 - cmdargs ==0.10.20 - directory ==1.3.1.5 + - extra ==1.6.13 - megaparsec ==6.5.0 - regex-posix ==0.95.2 - servant ==0.14.1 @@ -83,6 +84,7 @@ executables: - blaze-html ==0.9.1.1 - cmdargs ==0.10.20 - directory ==1.3.1.5 + - extra ==1.6.13 - megaparsec ==6.5.0 - regex-posix ==0.95.2 - servant ==0.14.1 @@ -114,6 +116,7 @@ tests: - blaze-html ==0.9.1.1 - cmdargs ==0.10.20 - directory ==1.3.1.5 + - extra ==1.6.13 - megaparsec ==6.5.0 - regex-posix ==0.95.2 - servant ==0.14.1 diff --git a/src/Server.hs b/src/Server.hs index ac947f1..c0f188d 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -26,9 +26,8 @@ import qualified Data.Text as T import qualified Data.Yaml as Y import Servant import System.Directory -import System.IO.HVFS +import System.Directory.Extra import qualified System.IO.Strict as SIO -import System.Path import System.Path.NameManip import Text.Blaze.Html5 (Html) import qualified Text.Blaze.Html5 as BZ @@ -319,7 +318,7 @@ getAllFiles :: ToodlesConfig -> FilePath -> IO [SourceFile] getAllFiles (ToodlesConfig ignoredPaths _) basePath = E.catch (do putStrLn $ printf "Running toodles for path: %s" basePath - files <- recurseDir SystemFS basePath + files <- listFilesInside (return . not . ignorePath) basePath let validFiles = filter isValidFile files mapM (\f -> @@ -333,20 +332,19 @@ getAllFiles (ToodlesConfig ignoredPaths _) basePath = where - isValidFile :: FilePath -> Bool - isValidFile path = fileHasValidExtension && not ignoreFile + ignorePath :: FilePath -> Bool + ignorePath path = + let p = T.pack path + in T.isInfixOf "node_modules" p || T.isSuffixOf "pb.go" p || + T.isSuffixOf "_pb2.py" p || + any (\r -> path =~ r :: Bool) ignoredPaths - where + fileHasValidExtension :: FilePath -> Bool + fileHasValidExtension path = any (\ext -> ext `T.isSuffixOf` T.pack path) (map extension fileTypeToComment) - fileHasValidExtension :: Bool - fileHasValidExtension = any (\ext -> ext `T.isSuffixOf` T.pack path) (map extension fileTypeToComment) + isValidFile :: FilePath -> Bool + isValidFile path = (not $ ignorePath path) && fileHasValidExtension path - ignoreFile :: Bool - ignoreFile = - let p = T.pack path - in T.isInfixOf "node_modules" p || T.isSuffixOf "pb.go" p || - T.isSuffixOf "_pb2.py" p || - any (\r -> path =~ r :: Bool) ignoredPaths mapHead :: (a -> a) -> [a] -> [a] mapHead f (x:xs) = f x : xs diff --git a/toodles.cabal b/toodles.cabal index 5bf28e8..dd151e2 100644 --- a/toodles.cabal +++ b/toodles.cabal @@ -1,10 +1,10 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.0. +-- This file has been generated from package.yaml by hpack version 0.31.1. -- -- see: https://github.com/sol/hpack -- --- hash: eca068224b8e938feec8b371e63c8819e81e6d2030806c1f220e08823596b7f7 +-- hash: 1b4520f165439b7fb3fce7f9d4d7a56afe20ac9ae86140d2b337e14f0517cbb6 name: toodles version: 1.0.2 @@ -56,6 +56,7 @@ library , blaze-html ==0.9.1.1 , cmdargs ==0.10.20 , directory ==1.3.1.5 + , extra ==1.6.13 , hspec >=2.4.4 , hspec-expectations >=0.8.2 , megaparsec ==6.5.0 @@ -90,6 +91,7 @@ executable toodles , blaze-html ==0.9.1.1 , cmdargs ==0.10.20 , directory ==1.3.1.5 + , extra ==1.6.13 , hspec >=2.4.4 , hspec-expectations >=0.8.2 , megaparsec ==6.5.0 @@ -125,6 +127,7 @@ test-suite toodles-test , blaze-html ==0.9.1.1 , cmdargs ==0.10.20 , directory ==1.3.1.5 + , extra ==1.6.13 , hspec >=2.4.4 , hspec-expectations >=0.8.2 , megaparsec ==6.5.0