diff options
| author | William Boman <william@redwill.se> | 2022-12-08 02:20:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-08 02:20:42 +0100 |
| commit | d97579ccd5689f9c6c365e841ea99c27954112ec (patch) | |
| tree | e3bde9951ef1d4489e090f5dd3b83aafb1cf4f9e /lua/mason-core/installer/init.lua | |
| parent | feat(platform): accept darwin (#743) (diff) | |
| download | mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar.gz mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar.bz2 mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar.lz mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar.xz mason-d97579ccd5689f9c6c365e841ea99c27954112ec.tar.zst mason-d97579ccd5689f9c6c365e841ea99c27954112ec.zip | |
refactor(installer): rename run_installer to exec_in_context (#744)
Diffstat (limited to 'lua/mason-core/installer/init.lua')
| -rw-r--r-- | lua/mason-core/installer/init.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lua/mason-core/installer/init.lua b/lua/mason-core/installer/init.lua index b5efa495..0d6c8dc9 100644 --- a/lua/mason-core/installer/init.lua +++ b/lua/mason-core/installer/init.lua @@ -58,11 +58,12 @@ end ---@async ---@param context InstallContext ----@param installer async fun(context: InstallContext) -function M.run_installer(context, installer) +---@param fn async fun(context: InstallContext) +function M.exec_in_context(context, fn) local thread = coroutine.create(function(...) - -- We wrap the installer with a function to allow it to be a spy instance (in which case it's not a function, but a metatable - coroutine.create expects functions only) - return installer(...) + -- We wrap the function to allow it to be a spy instance (in which case it's not actually a function, but a + -- callable metatable - coroutine.create strictly expects functions only) + return fn(...) end) local step local ret_val @@ -119,7 +120,7 @@ function M.execute(handle, opts) return Result.run_catching(function() -- 1. run installer a.wait(function(resolve, reject) - local cancel_thread = a.run(M.run_installer, function(success, result) + local cancel_thread = a.run(M.exec_in_context, function(success, result) if success then resolve(result) else @@ -183,7 +184,7 @@ end function M.run_concurrently(suspend_fns) local context = M.context() return a.wait_all(_.map(function(suspend_fn) - return _.partial(M.run_installer, context, suspend_fn) + return _.partial(M.exec_in_context, context, suspend_fn) end, suspend_fns)) end |
