aboutsummaryrefslogtreecommitdiff
path: root/src/HaskellCodeExplorer
diff options
context:
space:
mode:
authoralexwl <alexey.a.kiryushin@gmail.com>2018-11-13 18:52:47 +0300
committeralexwl <alexey.a.kiryushin@gmail.com>2018-11-13 18:52:47 +0300
commit9fa6772f29efec427269510c8bc85c9d8f8af5b4 (patch)
tree4eb8cea82e52789da70fc768695456dec3ed1b20 /src/HaskellCodeExplorer
parent71500f437dbc68395e2486efbcf14cc6cb007e51 (diff)
Check for the presence of stack.yaml in the parent directories. Fixes #13.
Diffstat (limited to 'src/HaskellCodeExplorer')
-rw-r--r--src/HaskellCodeExplorer/PackageInfo.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/HaskellCodeExplorer/PackageInfo.hs b/src/HaskellCodeExplorer/PackageInfo.hs
index b48ea9b..9be74e2 100644
--- a/src/HaskellCodeExplorer/PackageInfo.hs
+++ b/src/HaskellCodeExplorer/PackageInfo.hs
@@ -22,7 +22,7 @@ import Control.Exception
, try
)
import Control.Monad (foldM, join, unless)
-import Control.Monad.Extra (findM)
+import Control.Monad.Extra (anyM, findM)
import Control.Monad.Logger
( LoggingT(..)
, MonadLogger(..)
@@ -95,8 +95,7 @@ import Outputable (PprStyle, SDoc, neverQualify, showSDocForUser)
import Packages (initPackages)
import Prelude hiding (id)
import System.Directory
- ( doesFileExist
- , doesFileExist
+ ( doesFileExist
, findExecutable
, setCurrentDirectory
, getCurrentDirectory
@@ -112,7 +111,7 @@ import System.FilePath
, splitPath
, takeExtension
, takeBaseName
- , splitDirectories
+ , splitDirectories
)
import System.Process (readProcess)
@@ -313,7 +312,12 @@ addReferencesFromModule references modInfo@HCE.ModuleInfo {..} =
findDistDirectory :: FilePath -> LoggingT IO FilePath
findDistDirectory packagePath = do
- hasStackYaml <- liftIO $ doesFileExist (packagePath </> "stack.yaml")
+ let parents =
+ reverse . map joinPath . filter (not . null) . L.inits . splitPath $
+ packagePath
+ -- e.g., ["/dir/subdir/subsubdir","/dir/subdir/","/dir/","/"]
+ hasStackYaml <-
+ liftIO $ anyM (\path -> doesFileExist (path </> "stack.yaml")) parents
mbStackExecutable <- liftIO $ findExecutable "stack"
let defaultDistDir = packagePath </> "dist"
case (hasStackYaml, mbStackExecutable) of