Merge pull request #29 from tanakh/master

Change search method for "cabal-dev/"
This commit is contained in:
Kazu Yamamoto 2011-11-24 17:27:14 -08:00
commit 3102e488c9

View File

@ -7,6 +7,7 @@ If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the
options ghc-mod uses to check the source. Otherwise just pass it on. options ghc-mod uses to check the source. Otherwise just pass it on.
-} -}
import Control.Applicative ((<$>))
import Data.Maybe (listToMaybe) import Data.Maybe (listToMaybe)
import System.FilePath.Find import System.FilePath.Find
import System.FilePath.Posix (splitPath,joinPath,(</>)) import System.FilePath.Posix (splitPath,joinPath,(</>))
@ -37,9 +38,8 @@ searchIt [] = return Nothing
searchIt path = do searchIt path = do
a <- doesDirectoryExist (mpath path) a <- doesDirectoryExist (mpath path)
if a then do if a then do
b <- find always (fileName ~~? "packages*.conf") $ mpath path listToMaybe <$> find always (fileName ~~? "packages*.conf") (mpath path)
maybe (searchIt $ init path) (return . Just) $ listToMaybe b
else else
return Nothing searchIt $ init path
where where
mpath a = joinPath a </> "cabal-dev/" mpath a = joinPath a </> "cabal-dev/"