cosmetic change.
This commit is contained in:
parent
47e5a13b56
commit
718b3fa3df
36
CabalDev.hs
36
CabalDev.hs
@ -1,10 +1,8 @@
|
|||||||
-- {-# LANGUAGE DoAndIfThenElse #-} -- not in GHC 6.12.3
|
|
||||||
|
|
||||||
module CabalDev (modifyOptions) where
|
module CabalDev (modifyOptions) where
|
||||||
|
|
||||||
{-
|
{-
|
||||||
If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the
|
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 Control.Applicative ((<$>))
|
||||||
@ -17,33 +15,33 @@ import Types
|
|||||||
|
|
||||||
modifyOptions :: Options -> IO Options
|
modifyOptions :: Options -> IO Options
|
||||||
modifyOptions opts =
|
modifyOptions opts =
|
||||||
fmap (has_cdev opts) findCabalDev
|
fmap (has_cdev opts) findCabalDev
|
||||||
where
|
where
|
||||||
has_cdev :: Options -> Maybe String -> Options
|
has_cdev :: Options -> Maybe String -> Options
|
||||||
has_cdev op Nothing = op
|
has_cdev op Nothing = op
|
||||||
has_cdev op (Just path) = addPath op path
|
has_cdev op (Just path) = addPath op path
|
||||||
|
|
||||||
findCabalDev :: IO (Maybe String)
|
findCabalDev :: IO (Maybe String)
|
||||||
findCabalDev =
|
findCabalDev =
|
||||||
getCurrentDirectory >>= searchIt . splitPath
|
getCurrentDirectory >>= searchIt . splitPath
|
||||||
|
|
||||||
addPath :: Options -> String -> Options
|
addPath :: Options -> String -> Options
|
||||||
addPath orig_opts path = do
|
addPath orig_opts path = do
|
||||||
let orig_ghcopt = ghcOpts orig_opts
|
let orig_ghcopt = ghcOpts orig_opts
|
||||||
orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] }
|
orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] }
|
||||||
|
|
||||||
searchIt :: [FilePath] -> IO (Maybe FilePath)
|
searchIt :: [FilePath] -> IO (Maybe FilePath)
|
||||||
searchIt [] = return Nothing
|
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
|
||||||
findConf (mpath path)
|
findConf (mpath path)
|
||||||
else
|
else
|
||||||
searchIt $ init path
|
searchIt $ init path
|
||||||
where
|
where
|
||||||
mpath a = joinPath a </> "cabal-dev/"
|
mpath a = joinPath a </> "cabal-dev/"
|
||||||
|
|
||||||
findConf :: FilePath -> IO (Maybe FilePath)
|
findConf :: FilePath -> IO (Maybe FilePath)
|
||||||
findConf path = do
|
findConf path = do
|
||||||
f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path
|
f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path
|
||||||
return $ ((path </>) <$> f)
|
return $ ((path </>) <$> f)
|
||||||
|
Loading…
Reference in New Issue
Block a user