ghcid 0.6 → 0.6.1
raw patch · 5 files changed
+17/−10 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGES.txt +3/−0
- ghcid.cabal +1/−1
- src/Ghcid.hs +8/−6
- src/Test/Polling.hs +1/−1
- src/Wait.hs +4/−2
CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for GHCiD +0.6.1+ Add --reload to add files that reload, but do not restart+ #56, allow --restart to take directories 0.6 #38, implement loading with stack Add process, quit and execStream to the API
ghcid.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.10 build-type: Simple name: ghcid-version: 0.6+version: 0.6.1 license: BSD3 license-file: LICENSE category: Development
src/Ghcid.hs view
@@ -36,6 +36,7 @@ ,width :: Maybe Int ,topmost :: Bool ,notitle :: Bool+ ,reload :: [FilePath] ,restart :: [FilePath] ,directory :: FilePath ,outputfile :: [FilePath]@@ -52,6 +53,7 @@ ,topmost = False &= name "t" &= help "Set window topmost (Windows only)" ,notitle = False &= help "Don't update the shell title/icon" ,restart = [] &= typFile &= help "Restart the command if any of these files change (defaults to .ghci or .cabal)"+ ,reload = [] &= typFile &= help "Reload if any of these files change (defaults to none)" ,directory = "." &= typDir &= name "C" &= help "Set the current directory" ,outputfile = [] &= typFile &= name "o" &= help "File to write the full output to" } &= verbosity &=@@ -126,7 +128,7 @@ return (f width 80 (pred . fst), f height 8 snd) withWaiterNotify $ \waiter -> handle (\(UnexpectedExit cmd _) -> putStrLn $ "Command \"" ++ cmd ++ "\" exited unexpectedly") $- runGhcid session waiter (nubOrd restart) command outputfile test height (not notitle) $ \xs -> do+ runGhcid session waiter (nubOrd restart) (nubOrd reload) command outputfile test height (not notitle) $ \xs -> do outWith $ forM_ (groupOn fst xs) $ \x@((s,_):_) -> do when (s == Bold) $ setSGR [SetConsoleIntensity BoldIntensity] putStr $ concatMap ((:) '\n' . snd) x@@ -137,8 +139,8 @@ data Style = Plain | Bold deriving Eq -runGhcid :: Session -> Waiter -> [FilePath] -> String -> [FilePath] -> Maybe String -> IO (Int,Int) -> Bool -> ([(Style,String)] -> IO ()) -> IO ()-runGhcid session waiter restart command outputfiles test size titles output = do+runGhcid :: Session -> Waiter -> [FilePath] -> [FilePath] -> String -> [FilePath] -> Maybe String -> IO (Int,Int) -> Bool -> ([(Style,String)] -> IO ()) -> IO ()+runGhcid session waiter restart reload command outputfiles test size titles output = do let outputFill :: Maybe (Int, [Load]) -> [String] -> IO () outputFill load msg = do (width, height) <- size@@ -169,7 +171,7 @@ let f n msg = if n == 0 then "" else show n ++ " " ++ msg ++ ['s' | n > 1] in (if countErrors == 0 && countWarnings == 0 then allGoodMessage else f countErrors "error" ++ (if countErrors > 0 && countWarnings > 0 then ", " else "") ++ f countWarnings "warning") ++- " " ++ extra ++ "- " ++ takeFileName curdir+ " " ++ extra ++ [' ' | extra /= ""] ++ "- " ++ takeFileName curdir updateTitle $ if isJust test then "(running test) " else "" outputFill (Just (loadedCount, messages)) ["Running test..." | isJust test]@@ -184,14 +186,14 @@ whenLoud $ outStrLn "%TESTING: Completed" updateTitle "(test done)" - reason <- nextWait $ restart ++ loaded+ reason <- nextWait $ restart ++ reload ++ loaded outputFill Nothing $ "Reloading..." : map (" " ++) reason restartTimes2 <- mapM getModTime restart if restartTimes == restartTimes2 then do nextWait <- waitFiles waiter fire nextWait =<< sessionReload session else do- runGhcid session waiter restart command outputfiles test size titles output+ runGhcid session waiter restart reload command outputfiles test size titles output nextWait <- waitFiles waiter (messages, loaded) <- sessionStart session command
src/Test/Polling.hs view
@@ -42,7 +42,7 @@ try_ $ system "chmod og-w . .ghci" withSession $ \session -> withWaiterPoll $ \waiter -> bracket (- forkIO $ runGhcid session waiter [] "ghci" [] Nothing (return (100, 50)) False $ \msg ->+ forkIO $ runGhcid session waiter [] [] "ghci" [] Nothing (return (100, 50)) False $ \msg -> unless (isLoading $ map snd msg) $ putMVarNow ref $ map snd msg ) killThread $ \_ -> do require requireAllGood
src/Wait.hs view
@@ -7,11 +7,11 @@ import Control.Concurrent.Extra import qualified Data.Map as Map import qualified Data.Set as Set-import Control.Monad+import Control.Monad.Extra import Data.List.Extra import System.FilePath import Control.Exception.Extra-import System.Directory+import System.Directory.Extra import Data.Time.Clock import Data.String import Data.Maybe@@ -49,6 +49,8 @@ base <- getCurrentTime return $ \files -> handle (\(e :: IOError) -> do sleep 0.1; return [show e]) $ do whenLoud $ outStrLn $ "%WAITING: " ++ unwords files+ files <- fmap concat $ forM files $ \file ->+ ifM (doesDirectoryExist file) (listFiles file) (return [file]) case waiter of WaiterPoll -> return () WaiterNotify manager kick mp -> do