Commando 1.0.0.2 → 1.0.0.4
raw patch · 2 files changed
+5/−4 lines, 2 files
Files
- Commando.cabal +1/−1
- System/Commando.hs +4/−3
Commando.cabal view
@@ -1,5 +1,5 @@ name: Commando-version: 1.0.0.2+version: 1.0.0.4 synopsis: Watch some files; Rerun a command homepage: https://github.com/sordina/Commando license: MIT
System/Commando.hs view
@@ -7,7 +7,7 @@ import Prelude hiding (FilePath) import Control.Monad (void)-import System.Process (runInteractiveCommand)+import System.Process (waitForProcess, createProcess, CreateProcess, shell, proc, StdStream(..), runInteractiveCommand, terminateProcess) import System.FSNotify (startManager, watchTree, stopManager, Event(..)) import Filesystem.Path.CurrentOS (FilePath, fromText, toText) import Data.Text (pack, unpack)@@ -81,7 +81,7 @@ rc <- if persist o then Just <$> startPipe (command o) else return Nothing - void $ forkIO $ whenM rc $ \(_,so,_,_) -> hGetContents so >>= mapM_ (putChan c) . lines+ void $ forkIO $ whenM rc $ \(_,so,_,_) -> hGetContents so >>= mapM_ (putChan c . (++ "\n")) . lines let cmd = command o dsp = display o@@ -99,10 +99,11 @@ systemChan :: CH -> String -> [String] -> IO () systemChan c cmd as = do- (i,o,e,_) <- runInteractiveCommand (cmd ++ " " ++ (as >>= show))+ (i,o,e,pid) <- runInteractiveCommand (cmd ++ " " ++ (as >>= show)) hClose i hGetContents o >>= putChan c hGetContents e >>= putChan c+ void $ waitForProcess pid whenM :: Monad m => Maybe a -> (a -> m ()) -> m () whenM m f = maybe (return ()) f m