diff options
| -rw-r--r-- | lua/mason-core/async/init.lua | 6 | ||||
| -rw-r--r-- | tests/mason-core/installer/installer_spec.lua | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua index 05401ca2..3c88eef0 100644 --- a/lua/mason-core/async/init.lua +++ b/lua/mason-core/async/init.lua @@ -29,7 +29,7 @@ end local function await(resolver) local ok, value = co.yield(Promise.new(resolver)) if not ok then - error(value[1], 2) + error(value[1], 0) end return unpack(value) end @@ -38,8 +38,10 @@ local function table_pack(...) return { n = select("#", ...), ... } end ----@param async_fn fun(...) +---@generic T +---@param async_fn T ---@param should_reject_err boolean? Whether the provided async_fn takes a callback with the signature `fun(err, result)` +---@return T local function promisify(async_fn, should_reject_err) return function(...) local args = table_pack(...) diff --git a/tests/mason-core/installer/installer_spec.lua b/tests/mason-core/installer/installer_spec.lua index ead08f18..421de34b 100644 --- a/tests/mason-core/installer/installer_spec.lua +++ b/tests/mason-core/installer/installer_spec.lua @@ -47,7 +47,7 @@ describe("installer", function() local result = installer.execute(handler, {}) assert.spy(installer_fn).was_called(1) assert.is_true(result:is_failure()) - assert.is_true(match.has_match "^.*: something went wrong. don't try again.$"(result:err_or_nil())) + assert.equals("something went wrong. don't try again.", result:err_or_nil()) assert.spy(fs.async.rmrf).was_called_with(path.package_build_prefix "dummy") assert.spy(fs.async.rename).was_not_called() end) |
