From c0f46ef81f92c440b7cc2b9432cbb10ef33ad353 Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Fri, 23 Jul 2021 16:23:03 +0530 Subject: [PATCH] Factor out installHLS' --- lib/GHCup.hs | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 9bbe509..b859950 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -634,39 +634,38 @@ installHLSBindist dlinfo ver = do let lInstHLS = headMay . reverse . sort $ hlsVers when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver - where - -- | Install an unpacked hls distribution. - installHLS' :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m) - => FilePath -- ^ Path to the unpacked hls bindist (where the executable resides) - -> FilePath -- ^ Path to install to - -> Excepts '[CopyError] m () - installHLS' path inst = do - lift $ $(logInfo) "Installing HLS" - liftIO $ createDirRecursive' inst +-- | Install an unpacked hls distribution. +installHLS' :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m) + => FilePath -- ^ Path to the unpacked hls bindist (where the executable resides) + -> FilePath -- ^ Path to install to + -> Version + -> Excepts '[CopyError] m () +installHLS' path inst ver = do + lift $ $(logInfo) "Installing HLS" + liftIO $ createDirRecursive' inst - -- install haskell-language-server- - bins@(_:_) <- liftIO $ findFiles - path - (makeRegexOpts compExtended - execBlank - ([s|^haskell-language-server-[0-9].*$|] :: ByteString) - ) - forM_ bins $ \f -> do - let toF = dropSuffix exeExt f - <> "~" <> T.unpack (prettyVer ver) <> exeExt - handleIO (throwE . CopyError . show) $ liftIO $ copyFile - (path f) - (inst toF) - lift $ chmod_755 (inst toF) - - -- install haskell-language-server-wrapper - let wrapper = "haskell-language-server-wrapper" - toF = wrapper <> "-" <> T.unpack (prettyVer ver) <> exeExt + -- install haskell-language-server- + bins@(_:_) <- liftIO $ findFiles + path + (makeRegexOpts compExtended + execBlank + ([s|^haskell-language-server-[0-9].*$|] :: ByteString) + ) + forM_ bins $ \f -> do + let toF = dropSuffix exeExt f + <> "~" <> T.unpack (prettyVer ver) <> exeExt handleIO (throwE . CopyError . show) $ liftIO $ copyFile - (path wrapper <> exeExt) + (path f) (inst toF) lift $ chmod_755 (inst toF) + -- install haskell-language-server-wrapper + let wrapper = "haskell-language-server-wrapper" + toF = wrapper <> "-" <> T.unpack (prettyVer ver) <> exeExt + handleIO (throwE . CopyError . show) $ liftIO $ copyFile + (path wrapper <> exeExt) + (inst toF) + lift $ chmod_755 (inst toF) -- | Installs hls binaries @haskell-language-server-\@ -- into @~\/.ghcup\/bin/@, as well as @haskell-languager-server-wrapper@.