Factor out installHLS'

This commit is contained in:
Arjun Kathuria 2021-07-23 16:23:03 +05:30
parent 4729364e99
commit 9686ee9826

View File

@ -634,39 +634,38 @@ installHLSBindist dlinfo ver = do
let lInstHLS = headMay . reverse . sort $ hlsVers let lInstHLS = headMay . reverse . sort $ hlsVers
when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver when (maybe True (ver >=) lInstHLS) $ liftE $ setHLS ver
where -- | Install an unpacked hls distribution.
-- | Install an unpacked hls distribution. installHLS' :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m)
installHLS' :: (MonadFail m, MonadLogger m, MonadCatch m, MonadIO m) => FilePath -- ^ Path to the unpacked hls bindist (where the executable resides)
=> FilePath -- ^ Path to the unpacked hls bindist (where the executable resides) -> FilePath -- ^ Path to install to
-> FilePath -- ^ Path to install to -> Version
-> Excepts '[CopyError] m () -> Excepts '[CopyError] m ()
installHLS' path inst = do installHLS' path inst ver = do
lift $ $(logInfo) "Installing HLS" lift $ $(logInfo) "Installing HLS"
liftIO $ createDirRecursive' inst liftIO $ createDirRecursive' inst
-- install haskell-language-server-<ghcver> -- install haskell-language-server-<ghcver>
bins@(_:_) <- liftIO $ findFiles bins@(_:_) <- liftIO $ findFiles
path path
(makeRegexOpts compExtended (makeRegexOpts compExtended
execBlank execBlank
([s|^haskell-language-server-[0-9].*$|] :: ByteString) ([s|^haskell-language-server-[0-9].*$|] :: ByteString)
) )
forM_ bins $ \f -> do forM_ bins $ \f -> do
let toF = dropSuffix exeExt f let toF = dropSuffix exeExt f
<> "~" <> T.unpack (prettyVer ver) <> exeExt <> "~" <> 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
handleIO (throwE . CopyError . show) $ liftIO $ copyFile handleIO (throwE . CopyError . show) $ liftIO $ copyFile
(path </> wrapper <> exeExt) (path </> f)
(inst </> toF) (inst </> toF)
lift $ chmod_755 (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-\<ghcver\>@ -- | Installs hls binaries @haskell-language-server-\<ghcver\>@
-- into @~\/.ghcup\/bin/@, as well as @haskell-languager-server-wrapper@. -- into @~\/.ghcup\/bin/@, as well as @haskell-languager-server-wrapper@.