From 8b7c22440e706de09bedf34d14a66154cf8b960f Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Fri, 23 Jul 2021 15:51:56 +0530 Subject: [PATCH] factor out installCabal' from `installCabalBindist`, to be shared with `installCabalBinIsolated` function --- lib/GHCup.hs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 3f106f4..750746c 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -470,22 +470,22 @@ installCabalBindist dlinfo ver = do let lInstCabal = headMay . reverse . sort $ cVers when (maybe True (ver >=) lInstCabal) $ liftE $ setCabal ver - where - -- | Install an unpacked cabal distribution. - installCabal' :: (MonadLogger m, MonadCatch m, MonadIO m) - => FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides) - -> FilePath -- ^ Path to install to - -> Excepts '[CopyError] m () - installCabal' path inst = do - lift $ $(logInfo) "Installing cabal" - let cabalFile = "cabal" - liftIO $ createDirRecursive' inst - let destFileName = cabalFile <> "-" <> T.unpack (prettyVer ver) <> exeExt - let destPath = inst destFileName - handleIO (throwE . CopyError . show) $ liftIO $ copyFile - (path cabalFile <> exeExt) - destPath - lift $ chmod_755 destPath +-- | Install an unpacked cabal distribution. +installCabal' :: (MonadLogger m, MonadCatch m, MonadIO m) + => FilePath -- ^ Path to the unpacked cabal bindist (where the executable resides) + -> FilePath -- ^ Path to install to + -> Version + -> Excepts '[CopyError] m () +installCabal' path inst ver = do + lift $ $(logInfo) "Installing cabal" + let cabalFile = "cabal" + liftIO $ createDirRecursive' inst + let destFileName = cabalFile <> "-" <> T.unpack (prettyVer ver) <> exeExt + let destPath = inst destFileName + handleIO (throwE . CopyError . show) $ liftIO $ copyFile + (path cabalFile <> exeExt) + destPath + lift $ chmod_755 destPath -- | Installs cabal into @~\/.ghcup\/bin/cabal-\@ and