@@ -38,9 +38,10 @@ hlsVersion =
38
38
hlsGhcDisplayVersion = compilerName ++ " -" ++ VERSION_ghc
39
39
40
40
data ProgramsOfInterest = ProgramsOfInterest
41
- { cabalVersion :: Maybe Version
42
- , stackVersion :: Maybe Version
43
- , ghcVersion :: Maybe Version
41
+ { cabalVersion :: Maybe Version
42
+ , stackVersion :: Maybe Version
43
+ , ghcVersion :: Maybe Version
44
+ , stackGhcVersion :: Maybe Version
44
45
}
45
46
46
47
showProgramVersionOfInterest :: ProgramsOfInterest -> String
@@ -49,26 +50,27 @@ showProgramVersionOfInterest ProgramsOfInterest {..} =
49
50
[ " cabal:\t\t " ++ showVersionWithDefault cabalVersion
50
51
, " stack:\t\t " ++ showVersionWithDefault stackVersion
51
52
, " ghc:\t\t " ++ showVersionWithDefault ghcVersion
53
+ , " stack ghc:\t " ++ showVersionWithDefault stackGhcVersion
52
54
]
53
55
where
54
56
showVersionWithDefault :: Maybe Version -> String
55
57
showVersionWithDefault = maybe " Not found" showVersion
56
58
57
59
findProgramVersions :: IO ProgramsOfInterest
58
60
findProgramVersions = ProgramsOfInterest
59
- <$> findVersionOf " cabal"
60
- <*> findVersionOf " stack"
61
- <*> findVersionOf " ghc"
61
+ <$> findVersionOf " cabal" [" --numeric-version" ]
62
+ <*> findVersionOf " stack" [" --numeric-version" ]
63
+ <*> findVersionOf " ghc" [" --numeric-version" ]
64
+ <*> findVersionOf " stack" [" ghc" , " --" , " --numeric-version" ]
62
65
63
66
-- | Find the version of the given program.
64
- -- Assumes the program accepts the cli argument "--numeric-version".
65
67
-- If the invocation has a non-zero exit-code, we return 'Nothing'
66
- findVersionOf :: FilePath -> IO (Maybe Version )
67
- findVersionOf tool =
68
+ findVersionOf :: FilePath -> [ String ] -> IO (Maybe Version )
69
+ findVersionOf tool args =
68
70
findExecutable tool >>= \ case
69
71
Nothing -> pure Nothing
70
72
Just path ->
71
- readProcessWithExitCode path [ " --numeric-version " ] " " >>= \ case
73
+ readProcessWithExitCode path args " " >>= \ case
72
74
(ExitSuccess , sout, _) -> pure $ consumeParser myVersionParser sout
73
75
_ -> pure Nothing
74
76
where
0 commit comments