aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/installer/context/cwd.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-10-13 01:27:58 +0200
committerWilliam Boman <william@redwill.se>2025-02-19 09:23:19 +0100
commitc338fb2698ae276bc3b6edccdd3afaef92fc77bd (patch)
treeab9ec90f23e5ba1c48585fd41ef987cff8c3a693 /lua/mason-core/installer/context/cwd.lua
parentrefactor: add InstallLocation.global() (diff)
downloadmason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar.gz
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar.bz2
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar.lz
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar.xz
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.tar.zst
mason-c338fb2698ae276bc3b6edccdd3afaef92fc77bd.zip
refactor(installer): move initializations to InstallContext constructor
Diffstat (limited to 'lua/mason-core/installer/context/cwd.lua')
-rw-r--r--lua/mason-core/installer/context/cwd.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/lua/mason-core/installer/context/cwd.lua b/lua/mason-core/installer/context/cwd.lua
index 4f645fbb..cb2e70ec 100644
--- a/lua/mason-core/installer/context/cwd.lua
+++ b/lua/mason-core/installer/context/cwd.lua
@@ -4,27 +4,29 @@ local path = require "mason-core.path"
---@class InstallContextCwd
---@field private location InstallLocation Defines the upper boundary for which paths are allowed as cwd.
+---@field private handle InstallHandle
---@field private cwd string?
local InstallContextCwd = {}
InstallContextCwd.__index = InstallContextCwd
+---@param handle InstallHandle
---@param location InstallLocation
-function InstallContextCwd.new(location)
+function InstallContextCwd.new(handle, location)
assert(location, "location not provided")
return setmetatable({
location = location,
+ handle = handle,
cwd = nil,
}, InstallContextCwd)
end
----@param handle InstallHandle
-function InstallContextCwd:initialize(handle)
+function InstallContextCwd:initialize()
return Result.try(function(try)
- local staging_dir = self.location:staging(handle.package.name)
- if fs.async.dir_exists(staging_dir) then
- try(Result.pcall(fs.async.rmrf, staging_dir))
+ local staging_dir = self.location:staging(self.handle.package.name)
+ if fs.sync.dir_exists(staging_dir) then
+ try(Result.pcall(fs.sync.rmrf, staging_dir))
end
- try(Result.pcall(fs.async.mkdirp, staging_dir))
+ try(Result.pcall(fs.sync.mkdirp, staging_dir))
self:set(staging_dir)
end)
end