Merge pull request #30 from tanakh/master

remove dependency to unix module
This commit is contained in:
Kazu Yamamoto 2011-11-26 15:42:39 -08:00
commit 88528bea24
2 changed files with 12 additions and 8 deletions

View File

@ -8,11 +8,10 @@ options ghc-mod uses to check the source. Otherwise just pass it on.
-}
import Control.Applicative ((<$>))
import Data.Maybe (listToMaybe)
import System.FilePath.Find
import System.FilePath.Posix (splitPath,joinPath,(</>))
import System.Posix.Directory (getWorkingDirectory)
import Data.List (find)
import System.FilePath (splitPath,joinPath,(</>))
import System.Directory
import Text.Regex.Posix ((=~))
import Types
@ -26,7 +25,7 @@ modifyOptions opts =
findCabalDev :: IO (Maybe String)
findCabalDev =
getWorkingDirectory >>= searchIt . splitPath
getCurrentDirectory >>= searchIt . splitPath
addPath :: Options -> String -> Options
addPath orig_opts path = do
@ -38,8 +37,13 @@ searchIt [] = return Nothing
searchIt path = do
a <- doesDirectoryExist (mpath path)
if a then do
listToMaybe <$> find always (fileName ~~? "packages*.conf") (mpath path)
findConf (mpath path)
else
searchIt $ init path
where
mpath a = joinPath a </> "cabal-dev/"
findConf :: FilePath -> IO (Maybe FilePath)
findConf path = do
f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path
return $ ((path </>) <$> f)

View File

@ -29,8 +29,8 @@ Executable ghc-mod
else
GHC-Options: -Wall
Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths, transformers,
process, directory, filepath, old-time, unix,
hlint >= 1.7.1, filemanip,
process, directory, filepath, old-time,
hlint >= 1.7.1, regex-posix,
attoparsec, enumerator, attoparsec-enumerator
Source-Repository head
Type: git