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