From a2949cdb2be4b8e5c8290736d2916009f9526c3d Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Sat, 1 Aug 2015 17:03:33 +0200 Subject: Set default behaviour if no arguments given. --- html-test/run.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'html-test') 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"] -- cgit v1.2.3