diff options
author | Łukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-08-01 17:03:33 +0200 |
---|---|---|
committer | Łukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-08-22 23:40:26 +0200 |
commit | a2949cdb2be4b8e5c8290736d2916009f9526c3d (patch) | |
tree | ccc4b34fdb046997fdfef95e1ca5f6ec16d8ff58 /html-test/run.hs | |
parent | 0a7c9cc09882f4d0bd3a3c1b64d0ae8f2d7a2317 (diff) |
Set default behaviour if no arguments given.
Diffstat (limited to 'html-test/run.hs')
-rwxr-xr-x | html-test/run.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/html-test/run.hs b/html-test/run.hs index 71d78f73..99ca1ec1 100755 --- a/html-test/run.hs +++ b/html-test/run.hs @@ -2,6 +2,7 @@ {-# LANGUAGE CPP #-} +import System.Directory import System.Environment import System.FilePath @@ -18,11 +19,20 @@ outDir = baseDir </> "out" main :: IO () main = do - files <- map processArg <$> getArgs + files <- processArgs =<< getArgs putStrLn $ "Files to test: " ++ show files +processArgs :: [String] -> IO [FilePath] +processArgs [] = filter isSourceFile <$> getDirectoryContents srcDir +processArgs args = pure $ map processArg args + + processArg :: String -> FilePath processArg arg - | takeExtension arg `elem` [".hs", ".lhs"] = arg + | isSourceFile arg = arg | otherwise = srcDir </> arg <.> "hs" + + +isSourceFile :: FilePath -> Bool +isSourceFile path = takeExtension path `elem` [".hs", ".lhs"] |