vcswrapper 0.1.1 → 0.1.2
raw patch · 2 files changed
+22/−6 lines, 2 filesdep +containersdep ~basedep ~filepath
Dependencies added: containers
Dependency ranges changed: base, filepath
Files
- src/VCSWrapper/Common/Process.hs +15/−1
- vcswrapper.cabal +7/−5
src/VCSWrapper/Common/Process.hs view
@@ -20,6 +20,7 @@ ) where import System.Process+import System.Environment (getEnvironment) import System.Exit import System.IO (Handle, hFlush, hClose, hGetContents, hPutStr) import Control.Concurrent@@ -27,8 +28,10 @@ import qualified Control.Exception as Exc import VCSWrapper.Common.Types import Data.Maybe+import Data.Monoid (mconcat) import Data.Text (Text) import qualified Data.Text as T (null, unpack, pack)+import qualified Data.Map.Strict as Map import Control.Monad (unless) -- | Internal function to execute a VCS command. Throws an exception if the command fails.@@ -104,16 +107,27 @@ {- |+ Combines the given environment variables and the environment variables of the current process, with the+ given environment variables taking priority in the case of a conflict.+-}+inheritCurrentEnvironment :: [(Text, Text)] -> IO [(String, String)]+inheritCurrentEnvironment menv = do+ currentEnv <- getEnvironment+ let menv' = map (\(k,v) -> (T.unpack k, T.unpack v)) menv+ return . Map.toList . mconcat $ map Map.fromList [menv', currentEnv]++{- | Setting pipes as in 'System.Process.readProcessWithExitCode' in ' but having a configurable working directory and environment. -} execProcWithPipes :: Maybe FilePath -> FilePath -> [Text] -> [(Text, Text)] -> IO (Handle, Handle, Handle, ProcessHandle) execProcWithPipes mcwd command args menv = do+ env' <- inheritCurrentEnvironment menv (Just inh, Just outh, Just errh, pid) <- createProcess (proc command (map T.unpack args)) { std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe, cwd = mcwd,- env = Just (map (\(k,v) -> (T.unpack k, T.unpack v)) menv) }+ env = Just env' } return (inh, outh, errh, pid)
vcswrapper.cabal view
@@ -1,5 +1,5 @@ name: vcswrapper-version: 0.1.1+version: 0.1.2 cabal-version: >= 1.8 build-type: Simple license: GPL@@ -20,13 +20,14 @@ library build-depends:- base >=4.0.0.0 && <4.8,+ base >=4.0.0.0 && <4.9,+ containers >=0.5.5.1 && <0.6, directory >=1.1.0.0 && <1.3, hxt >=9.1.2 && <9.4, mtl >=2.0.1.0 && <2.3, parsec >=3.1.1 && <3.2, process >=1.0.1.5 && <1.3,- filepath >=1.2.0.0 && < 1.4,+ filepath >=1.2.0.0 && < 1.5, split >=0.2.2 && <0.3, text >=0.11.1.5 && <1.3 exposed-modules: VCSWrapper.Common VCSWrapper.Git VCSWrapper.Svn VCSWrapper.Mercurial@@ -43,13 +44,14 @@ executable vcswrapper main-is: Main.hs build-depends:- base >=4.0.0.0 && <4.8,+ base >=4.0.0.0 && <4.9,+ containers >=0.5.5.1 && <0.6, directory >=1.1.0.0 && <1.3, hxt >=9.1.2 && <9.4, mtl >=2.0.1.0 && <2.3, parsec >=3.1.1 && <3.2, process >=1.0.1.5 && <1.3,- filepath >=1.2.0.0 && < 1.4,+ filepath >=1.2.0.0 && < 1.5, split >=0.2.2 && <0.3, text >=0.11.1.5 && <1.3 buildable: True