Merge pull request #30 from tanakh/master
remove dependency to unix module
This commit is contained in:
commit
88528bea24
16
CabalDev.hs
16
CabalDev.hs
@ -8,11 +8,10 @@ options ghc-mod uses to check the source. Otherwise just pass it on.
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
import Control.Applicative ((<$>))
|
import Control.Applicative ((<$>))
|
||||||
import Data.Maybe (listToMaybe)
|
import Data.List (find)
|
||||||
import System.FilePath.Find
|
import System.FilePath (splitPath,joinPath,(</>))
|
||||||
import System.FilePath.Posix (splitPath,joinPath,(</>))
|
|
||||||
import System.Posix.Directory (getWorkingDirectory)
|
|
||||||
import System.Directory
|
import System.Directory
|
||||||
|
import Text.Regex.Posix ((=~))
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ modifyOptions opts =
|
|||||||
|
|
||||||
findCabalDev :: IO (Maybe String)
|
findCabalDev :: IO (Maybe String)
|
||||||
findCabalDev =
|
findCabalDev =
|
||||||
getWorkingDirectory >>= searchIt . splitPath
|
getCurrentDirectory >>= searchIt . splitPath
|
||||||
|
|
||||||
addPath :: Options -> String -> Options
|
addPath :: Options -> String -> Options
|
||||||
addPath orig_opts path = do
|
addPath orig_opts path = do
|
||||||
@ -38,8 +37,13 @@ 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
|
||||||
listToMaybe <$> find always (fileName ~~? "packages*.conf") (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 path = do
|
||||||
|
f <- find (=~ "packages.*\\.conf") <$> getDirectoryContents path
|
||||||
|
return $ ((path </>) <$> f)
|
||||||
|
@ -29,8 +29,8 @@ Executable ghc-mod
|
|||||||
else
|
else
|
||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths, transformers,
|
Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths, transformers,
|
||||||
process, directory, filepath, old-time, unix,
|
process, directory, filepath, old-time,
|
||||||
hlint >= 1.7.1, filemanip,
|
hlint >= 1.7.1, regex-posix,
|
||||||
attoparsec, enumerator, attoparsec-enumerator
|
attoparsec, enumerator, attoparsec-enumerator
|
||||||
Source-Repository head
|
Source-Repository head
|
||||||
Type: git
|
Type: git
|
||||||
|
Loading…
Reference in New Issue
Block a user