packages feed

arion 0.1.0.2 → 0.1.0.3

raw patch · 4 files changed

+14/−14 lines, 4 files

Files

arion.cabal view
@@ -1,5 +1,5 @@ name:                arion-version:             0.1.0.2+version:             0.1.0.3 synopsis:            Watcher and runner for Hspec description:         Watcher and runner for Hspec license:             PublicDomain
src/Arion/EventProcessor.hs view
@@ -10,19 +10,19 @@ import qualified Data.Map as M import Arion.Help -processEvent :: SourceTestMap -> Event -> [Command]-processEvent sourceToTestFileMap (Modified filePath _) = commands sourceToTestFileMap (encodeString filePath)-processEvent sourceToTestFileMap (Added filePath _) = commands sourceToTestFileMap (encodeString filePath)-processEvent _ _ = []+processEvent :: SourceTestMap -> String -> Event -> [Command]+processEvent sourceToTestFileMap sourceFolder (Modified filePath _) = commands sourceToTestFileMap sourceFolder (encodeString filePath)+processEvent sourceToTestFileMap sourceFolder (Added filePath _) = commands sourceToTestFileMap sourceFolder (encodeString filePath)+processEvent _ _ _ = [] -commands :: SourceTestMap -> FilePath -> [Command]-commands sourceToTestFileMap filePath +commands :: SourceTestMap -> String -> FilePath -> [Command]+commands sourceToTestFileMap sourceFolder filePath         | isSuffixOf "hs" filePath = let fileType = typeOf filePath                                          commandCandidates = case fileType of                                                                Source -> let testFiles = M.lookup filePath sourceToTestFileMap                                                                          in toCommandCandidates testFiles                                                                Test -> [filePath]-                                     in Echo (filePath ++ " changed") : map RunHaskell commandCandidates+                                     in Echo (filePath ++ " changed") : map (RunHaskell sourceFolder) commandCandidates         | otherwise = []  toCommandCandidates :: Maybe [TestFile] -> [String]
src/Arion/Runner.hs view
@@ -35,7 +35,7 @@                                          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)+                                         _ <- watchTree manager (fromText $ pack path) (const True) (eventHandler sourceToTestFileMap sourceFolder)                                          forever $ threadDelay maxBound  filePathAndContent :: String -> IO (FilePath, FileContent)@@ -47,9 +47,9 @@ findHaskellFiles :: String -> IO [String] findHaskellFiles = find always (extension ==? ".hs" ||? extension ==? ".lhs") -eventHandler :: SourceTestMap -> Event -> IO ()-eventHandler sourceToTestFileMap event = let commands = processEvent sourceToTestFileMap event-                                         in mapM_ executeCommand commands+eventHandler :: SourceTestMap -> String -> Event -> IO ()+eventHandler sourceToTestFileMap sourceFolder event = let commands = processEvent sourceToTestFileMap sourceFolder event+                                                      in mapM_ executeCommand commands  executeCommand :: Command -> IO () executeCommand command = let process = (try . callCommand) (show command) :: IO (Either SomeException ())
src/Arion/Types.hs view
@@ -15,10 +15,10 @@ import Text.Regex.Posix import Data.Map (Map) -data Command = RunHaskell { commandString :: String } | Echo String deriving (Eq)+data Command = RunHaskell { sourceFolder :: String, commandString :: String } | Echo String deriving (Eq)  instance Show Command where-    show (RunHaskell commandString) = "runhaskell -isrc " ++ commandString+    show (RunHaskell sourceFolder commandString) = "runhaskell -i" ++ sourceFolder ++ " " ++ commandString     show (Echo stringToEcho) = "echo " ++ stringToEcho  type FileContent = String