Skip to content

Commit edc3420

Browse files
committed
Fix: #42
1 parent 4ffdec8 commit edc3420

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

implicit-hie-cradle.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cabal-version: 1.12
77
-- hash: 5c092074b2128d5593e67e2ace6e214ab27a89b73a7a71a71b212a4b34868b86
88

99
name: implicit-hie-cradle
10-
version: 0.3.0.5
10+
version: 0.4.0.0
1111
description: Auto generate a stack or cabal multi component cradles
1212
category: Development, Tools, Hie, HLS
1313
synopsis: Auto generate hie-bios cradles

src/Hie/Implicit/Cradle.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ where
1414
import Control.Applicative ((<|>))
1515
import Control.Exception (handleJust)
1616
import Control.Monad
17+
import Control.Monad.Extra (ifM)
1718
import Control.Monad.IO.Class
1819
import Control.Monad.Trans.Maybe
1920
import Data.Maybe
@@ -27,6 +28,7 @@ import Hie.Yaml
2728
import System.Directory hiding (findFile)
2829
import System.FilePath
2930
import System.IO.Error (isPermissionError)
31+
import System.Process (readProcess)
3032

3133
-- | Given root\/foo\/bar.hs, load an implicit cradle
3234
loadImplicitHieCradle :: FilePath -> IO (Cradle a)
@@ -64,7 +66,7 @@ implicitConfig' fp =
6466
c <- cn <$> readPkgs cc gp p
6567
pure (c, p)
6668
cabal :: FilePath -> MaybeT IO (CradleType a, FilePath)
67-
cabal = build (CabalMulti mempty) cabalComponent' cabalPkgs
69+
cabal = ifM ((>= "3.4") <$> liftIO cabalVersion) (pure (Cabal mempty, mempty)) . build (CabalMulti mempty) cabalComponent' cabalPkgs
6870
stack :: FilePath -> MaybeT IO (CradleType a, FilePath)
6971
stack = build (StackMulti mempty) stackComponent' stackYamlPkgs
7072
components f (Package n cs) = map (f n) cs
@@ -157,3 +159,6 @@ findContent p dir = do
157159

158160
biosWorkDir :: FilePath -> MaybeT IO FilePath
159161
biosWorkDir = findFileUpwards (".hie-bios" ==)
162+
163+
cabalVersion :: IO String
164+
cabalVersion = (!! 2) . words <$> readProcess "cabal" ["--version"] ""

0 commit comments

Comments
 (0)