arion 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+15/−11 lines, 3 files
Files
- arion.cabal +1/−1
- src/Arion/Runner.hs +12/−8
- src/Arion/Types.hs +2/−2
arion.cabal view
@@ -1,5 +1,5 @@ name: arion-version: 0.1.0.1+version: 0.1.0.2 synopsis: Watcher and runner for Hspec description: Watcher and runner for Hspec license: PublicDomain
src/Arion/Runner.hs view
@@ -29,16 +29,20 @@ | otherwise = putStrLn "Try arion --help for more information" startWatching :: String -> String -> String -> WatchManager -> IO ()-startWatching path sourceFolder testFolder manager = let sourceFiles = map (uncurry toSourceFile) <$> (mapM filePathAndContent =<< findHaskellFiles sourceFolder)- testFiles = map (uncurry toTestFile) <$> (mapM filePathAndContent =<< findHaskellFiles testFolder)- sourceToTestFileMap = associate <$> sourceFiles <*> testFiles- watchTreeWithHandler = watchTree manager (fromText $ pack path) (const True)- in (watchTreeWithHandler =<< (eventHandler <$> sourceToTestFileMap)) >> (forever $ threadDelay maxBound)+startWatching path sourceFolder testFolder manager = do+ sourceFilePathAndContent <- mapM filePathAndContent =<< findHaskellFiles sourceFolder+ testFilePathAndContent <- mapM filePathAndContent =<< findHaskellFiles testFolder+ let sourceFiles = map (uncurry toSourceFile) sourceFilePathAndContent+ let testFiles = map (uncurry toTestFile) testFilePathAndContent+ let sourceToTestFileMap = associate sourceFiles testFiles+ _ <- watchTree manager (fromText $ pack path) (const True) (eventHandler sourceToTestFileMap)+ forever $ threadDelay maxBound filePathAndContent :: String -> IO (FilePath, FileContent)-filePathAndContent relativePath = let canonicalizedPath = canonicalizePath relativePath- content = readFile =<< canonicalizedPath- in liftM2 (,) canonicalizedPath content+filePathAndContent relativePath = do+ canonicalizedPath <- canonicalizePath relativePath+ content <- readFile canonicalizedPath+ return (canonicalizedPath, content) findHaskellFiles :: String -> IO [String] findHaskellFiles = find always (extension ==? ".hs" ||? extension ==? ".lhs")
src/Arion/Types.hs view
@@ -75,6 +75,6 @@ importedModule _ = "" getModuleName :: FileContent -> String-getModuleName fileContent = let moduleLine = fileContent =~ "(module\\s+.*\\s+where)" :: String- [_, moduleName, _] = splitOn " " moduleLine+getModuleName fileContent = let moduleLine = fileContent =~ "(module\\s+.*\\s+.*)" :: String+ (_:moduleName:_)= splitOn " " moduleLine in moduleName