Skip to content

Commit f8d0129

Browse files
author
Tristan Webb
committed
Revert "Additional helper to get project config dir"
This reverts commit e324f19.
1 parent e324f19 commit f8d0129

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/Stack/Config.hs

+11-22
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,22 @@ loadYaml path = do
529529
logJSONWarnings (toFilePath path) warnings
530530
return result
531531

532-
-- | Get the parent directory the project config file, if it exists.
533-
getProjectConfigDir :: (MonadIO m, MonadThrow m, MonadLogger m)
534-
=> m (Maybe (Path Abs Dir))
535-
getProjectConfigDir = do
532+
-- | Get the location of the project config file, if it exists.
533+
getProjectConfig :: (MonadIO m, MonadThrow m, MonadLogger m)
534+
=> Maybe (Path Abs File)
535+
-- ^ Override stack.yaml
536+
-> m (Maybe (Path Abs File))
537+
getProjectConfig (Just stackYaml) = return $ Just stackYaml
538+
getProjectConfig Nothing = do
536539
env <- liftIO getEnvironment
537540
case lookup "STACK_YAML" env of
538541
Just fp -> do
539542
$logInfo "Getting project config file from STACK_YAML environment"
540543
liftM Just $ case parseAbsFile fp of
541544
Left _ -> do
542545
currDir <- getWorkingDir
543-
fmap parent (resolveFile currDir fp)
544-
Right path -> return (parent path)
546+
resolveFile currDir fp
547+
Right path -> return path
545548
Nothing -> do
546549
currDir <- getWorkingDir
547550
search currDir
@@ -552,28 +555,14 @@ getProjectConfigDir = do
552555
$logDebug $ "Checking for project config at: " <> T.pack fp'
553556
exists <- fileExists fp
554557
if exists
555-
then return $ Just dir
558+
then return $ Just fp
556559
else do
557560
let dir' = parent dir
558561
if dir == dir'
559562
-- fully traversed, give up
560563
then return Nothing
561564
else search dir'
562565

563-
-- | Get the path of the project config file, if it exists.
564-
getProjectConfigFile :: (MonadIO m, MonadThrow m, MonadLogger m)
565-
=> Maybe (Path Abs File)
566-
-- ^ Override stack.yaml
567-
-> m (Maybe (Path Abs File))
568-
getProjectConfigFile (Just stackYaml) = return $ Just stackYaml
569-
getProjectConfigFile Nothing =
570-
getProjectConfigDir >>= \case
571-
Nothing ->
572-
return Nothing
573-
Just dir ->
574-
return $
575-
Just (dir </> stackDotYaml)
576-
577566
-- | Find the project config file location, respecting environment variables
578567
-- and otherwise traversing parents. If no config is found, we supply a default
579568
-- based on current directory.
@@ -582,7 +571,7 @@ loadProjectConfig :: (MonadIO m, MonadThrow m, MonadLogger m)
582571
-- ^ Override stack.yaml
583572
-> m (Maybe (Project, Path Abs File, ConfigMonoid))
584573
loadProjectConfig mstackYaml = do
585-
mfp <- getProjectConfigFile mstackYaml
574+
mfp <- getProjectConfig mstackYaml
586575
case mfp of
587576
Just fp -> do
588577
currDir <- getWorkingDir

0 commit comments

Comments
 (0)