From 8f6a7ba39c98afdc7b6d008b6d528c74bb9294c8 Mon Sep 17 00:00:00 2001 From: Arjun Kathuria Date: Fri, 23 Jul 2021 16:43:43 +0530 Subject: [PATCH] factor out installStack' function --- lib/GHCup.hs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 4e3b9d9..2e7dc85 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -854,23 +854,23 @@ installStackBindist dlinfo ver = do let lInstStack = headMay . reverse . sort $ sVers when (maybe True (ver >=) lInstStack) $ liftE $ setStack ver - where - -- | Install an unpacked stack distribution. - installStack' :: (MonadLogger m, MonadCatch m, MonadIO m) - => FilePath -- ^ Path to the unpacked stack bindist (where the executable resides) - -> FilePath -- ^ Path to install to - -> Excepts '[CopyError] m () - installStack' path inst = do - lift $ $(logInfo) "Installing stack" - let stackFile = "stack" - liftIO $ createDirRecursive' inst - let destFileName = stackFile <> "-" <> T.unpack (prettyVer ver) <> exeExt - let destPath = inst destFileName - handleIO (throwE . CopyError . show) $ liftIO $ copyFile - (path stackFile <> exeExt) - destPath - lift $ chmod_755 destPath +-- | Install an unpacked stack distribution. +installStack' :: (MonadLogger m, MonadCatch m, MonadIO m) + => FilePath -- ^ Path to the unpacked stack bindist (where the executable resides) + -> FilePath -- ^ Path to install to + -> Version + -> Excepts '[CopyError] m () +installStack' path inst ver = do + lift $ $(logInfo) "Installing stack" + let stackFile = "stack" + liftIO $ createDirRecursive' inst + let destFileName = stackFile <> "-" <> T.unpack (prettyVer ver) <> exeExt + let destPath = inst destFileName + handleIO (throwE . CopyError . show) $ liftIO $ copyFile + (path stackFile <> exeExt) + destPath + lift $ chmod_755 destPath