Merge remote-tracking branch 'origin/merge-requests/149'
This commit is contained in:
commit
b086261c3c
41
lib/GHCup.hs
41
lib/GHCup.hs
@ -473,6 +473,9 @@ installCabalUnpacked path inst mver' = do
|
|||||||
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
||||||
<> exeExt
|
<> exeExt
|
||||||
let destPath = inst </> destFileName
|
let destPath = inst </> destFileName
|
||||||
|
|
||||||
|
liftE $ throwIfFileAlreadyExists destPath
|
||||||
|
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
(path </> cabalFile <> exeExt)
|
(path </> cabalFile <> exeExt)
|
||||||
destPath
|
destPath
|
||||||
@ -605,20 +608,32 @@ installHLSUnpacked path inst mver' = do
|
|||||||
let toF = dropSuffix exeExt f
|
let toF = dropSuffix exeExt f
|
||||||
<> maybe "" (("~" <>) . T.unpack . prettyVer) mver'
|
<> maybe "" (("~" <>) . T.unpack . prettyVer) mver'
|
||||||
<> exeExt
|
<> exeExt
|
||||||
|
|
||||||
|
let srcPath = path </> f
|
||||||
|
let destPath = inst </> toF
|
||||||
|
|
||||||
|
liftE $ throwIfFileAlreadyExists destPath
|
||||||
|
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
(path </> f)
|
srcPath
|
||||||
(inst </> toF)
|
destPath
|
||||||
lift $ chmod_755 (inst </> toF)
|
lift $ chmod_755 destPath
|
||||||
|
|
||||||
-- install haskell-language-server-wrapper
|
-- install haskell-language-server-wrapper
|
||||||
let wrapper = "haskell-language-server-wrapper"
|
let wrapper = "haskell-language-server-wrapper"
|
||||||
toF = wrapper
|
toF = wrapper
|
||||||
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
||||||
<> exeExt
|
<> exeExt
|
||||||
|
srcWrapperPath = path </> wrapper <> exeExt
|
||||||
|
destWrapperPath = inst </> toF
|
||||||
|
|
||||||
|
liftE $ throwIfFileAlreadyExists destWrapperPath
|
||||||
|
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
(path </> wrapper <> exeExt)
|
srcWrapperPath
|
||||||
(inst </> toF)
|
destWrapperPath
|
||||||
lift $ chmod_755 (inst </> toF)
|
|
||||||
|
lift $ chmod_755 destWrapperPath
|
||||||
|
|
||||||
-- | 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@.
|
||||||
@ -763,7 +778,7 @@ installStackUnpacked :: (MonadLogger m, MonadCatch m, MonadIO m)
|
|||||||
=> FilePath -- ^ Path to the unpacked stack bindist (where the executable resides)
|
=> FilePath -- ^ Path to the unpacked stack bindist (where the executable resides)
|
||||||
-> FilePath -- ^ Path to install to
|
-> FilePath -- ^ Path to install to
|
||||||
-> Maybe Version -- ^ Nothing for isolated installs
|
-> Maybe Version -- ^ Nothing for isolated installs
|
||||||
-> Excepts '[CopyError] m ()
|
-> Excepts '[CopyError, FileAlreadyExistsError] m ()
|
||||||
installStackUnpacked path inst mver' = do
|
installStackUnpacked path inst mver' = do
|
||||||
lift $ $(logInfo) "Installing stack"
|
lift $ $(logInfo) "Installing stack"
|
||||||
let stackFile = "stack"
|
let stackFile = "stack"
|
||||||
@ -771,7 +786,10 @@ installStackUnpacked path inst mver' = do
|
|||||||
let destFileName = stackFile
|
let destFileName = stackFile
|
||||||
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
<> maybe "" (("-" <>) . T.unpack . prettyVer) mver'
|
||||||
<> exeExt
|
<> exeExt
|
||||||
let destPath = inst </> destFileName
|
destPath = inst </> destFileName
|
||||||
|
|
||||||
|
liftE $ throwIfFileAlreadyExists destPath
|
||||||
|
|
||||||
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
handleIO (throwE . CopyError . show) $ liftIO $ copyFile
|
||||||
(path </> stackFile <> exeExt)
|
(path </> stackFile <> exeExt)
|
||||||
destPath
|
destPath
|
||||||
@ -2348,3 +2366,10 @@ whereIsTool tool ver@GHCTargetVersion {..} = do
|
|||||||
liftIO $ canonicalizePath currentRunningExecPath
|
liftIO $ canonicalizePath currentRunningExecPath
|
||||||
|
|
||||||
|
|
||||||
|
throwIfFileAlreadyExists :: ( MonadIO m ) =>
|
||||||
|
FilePath ->
|
||||||
|
Excepts '[FileAlreadyExistsError] m ()
|
||||||
|
|
||||||
|
throwIfFileAlreadyExists fp = whenM (checkFileAlreadyExists fp)
|
||||||
|
(throwE $ FileAlreadyExistsError fp)
|
||||||
|
|
||||||
|
@ -102,3 +102,6 @@ findFiles path regex = do
|
|||||||
contents <- listDirectory path
|
contents <- listDirectory path
|
||||||
pure $ filter (match regex) contents
|
pure $ filter (match regex) contents
|
||||||
|
|
||||||
|
|
||||||
|
checkFileAlreadyExists :: (MonadIO m) => FilePath -> m Bool
|
||||||
|
checkFileAlreadyExists fp = liftIO $ doesFileExist fp
|
||||||
|
Loading…
Reference in New Issue
Block a user