aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2023-10-13 21:14:29 +0200
committerWilliam Boman <william@redwill.se>2025-02-19 09:23:19 +0100
commitae208dc380808ff1aef39929a0e897e881571d43 (patch)
treeb9044cec7223062db69998189c76f8163ac9d58b
parentfix(location): use correct registry path (diff)
downloadmason-ae208dc380808ff1aef39929a0e897e881571d43.tar
mason-ae208dc380808ff1aef39929a0e897e881571d43.tar.gz
mason-ae208dc380808ff1aef39929a0e897e881571d43.tar.bz2
mason-ae208dc380808ff1aef39929a0e897e881571d43.tar.lz
mason-ae208dc380808ff1aef39929a0e897e881571d43.tar.xz
mason-ae208dc380808ff1aef39929a0e897e881571d43.tar.zst
mason-ae208dc380808ff1aef39929a0e897e881571d43.zip
refactor: standardize constructors and improve inheritance construction
-rw-r--r--doc/reference.md8
-rw-r--r--lua/mason-core/EventEmitter.lua8
-rw-r--r--lua/mason-core/async/control.lua58
-rw-r--r--lua/mason-core/async/init.lua12
-rw-r--r--lua/mason-core/installer/context/cwd.lua14
-rw-r--r--lua/mason-core/installer/context/fs.lua8
-rw-r--r--lua/mason-core/installer/context/init.lua10
-rw-r--r--lua/mason-core/installer/context/spawn.lua10
-rw-r--r--lua/mason-core/installer/handle.lua46
-rw-r--r--lua/mason-core/installer/location.lua12
-rw-r--r--lua/mason-core/installer/runner.lua16
-rw-r--r--lua/mason-core/optional.lua14
-rw-r--r--lua/mason-core/package.lua31
-rw-r--r--lua/mason-core/receipt.lua26
-rw-r--r--lua/mason-core/result.lua22
-rw-r--r--lua/mason-core/ui/display.lua2
-rw-r--r--lua/mason-registry/installer.lua2
-rw-r--r--lua/mason-registry/sources/file.lua10
-rw-r--r--lua/mason-registry/sources/github.lua18
-rw-r--r--lua/mason-registry/sources/init.lua6
-rw-r--r--lua/mason-registry/sources/lua.lua12
-rw-r--r--lua/mason-registry/sources/util.lua2
-rw-r--r--lua/mason-test/helpers.lua4
-rw-r--r--lua/mason/health.lua2
-rw-r--r--lua/mason/ui/instance.lua2
-rw-r--r--tests/helpers/lua/dummy-registry/dummy2_package.lua2
-rw-r--r--tests/helpers/lua/dummy-registry/dummy_package.lua2
-rw-r--r--tests/helpers/lua/dummy-registry/registry_package.lua2
-rw-r--r--tests/mason-core/async/async_spec.lua18
-rw-r--r--tests/mason-core/installer/handle_spec.lua10
-rw-r--r--tests/mason-core/installer/runner_spec.lua56
-rw-r--r--tests/mason-core/package/package_spec.lua12
-rw-r--r--tests/mason-core/receipt_spec.lua12
-rw-r--r--tests/mason-registry/sources/lua_spec.lua10
34 files changed, 272 insertions, 207 deletions
diff --git a/doc/reference.md b/doc/reference.md
index ef00425c..23eb306c 100644
--- a/doc/reference.md
+++ b/doc/reference.md
@@ -32,7 +32,7 @@ RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as de
- [`Package.Lang`](#packagelang)
- [`Package.Cat`](#packagecat)
- [`Package.License`](#packagelicense)
- - [`Package.new({spec})`](#packagenewspec)
+ - [`Package:new({spec})`](#packagenewspec)
- [`Package.spec`](#packagespec)
- [`Package:is_installing()`](#packageis_installing)
- [`Package:install({opts?}, {callback?})`](#packageinstallopts-callback)
@@ -184,7 +184,7 @@ Package.Cat = {
Similar as [`Package.Lang`](#packagelang) but for SPDX license identifiers.
-### `Package.new({spec})`
+### `Package:new({spec})`
**Parameters:**
@@ -312,7 +312,7 @@ The `.stdio_sink` property can be used to send stdout or stderr output, to be pr
Example:
```lua
-Pkg.new {
+local pkg = Pkg:new {
--- ...
---@async
---@param ctx InstallContext
@@ -339,7 +339,7 @@ registered with the relevant `InstallHandle`.
Example usage:
```lua
-Pkg.new {
+local pkg = Pkg:new {
--- ...
---@async
---@param ctx InstallContext
diff --git a/lua/mason-core/EventEmitter.lua b/lua/mason-core/EventEmitter.lua
index 7d95827f..8a936cb9 100644
--- a/lua/mason-core/EventEmitter.lua
+++ b/lua/mason-core/EventEmitter.lua
@@ -5,8 +5,12 @@ local log = require "mason-core.log"
local EventEmitter = {}
EventEmitter.__index = EventEmitter
-function EventEmitter.new()
- return EventEmitter.init(setmetatable({}, EventEmitter))
+function EventEmitter:new()
+ local instance = {}
+ setmetatable(instance, self)
+ instance.__event_handlers = {}
+ instance.__event_handlers_once = {}
+ return instance
end
---@generic T
diff --git a/lua/mason-core/async/control.lua b/lua/mason-core/async/control.lua
index 57aa88db..2388bce5 100644
--- a/lua/mason-core/async/control.lua
+++ b/lua/mason-core/async/control.lua
@@ -4,8 +4,12 @@ local a = require "mason-core.async"
local Condvar = {}
Condvar.__index = Condvar
-function Condvar.new()
- return setmetatable({ handles = {} }, Condvar)
+function Condvar:new()
+ ---@type Condvar
+ local instance = {}
+ setmetatable(instance, self)
+ instance.handles = {}
+ return instance
end
---@async
@@ -31,8 +35,12 @@ end
local Permit = {}
Permit.__index = Permit
-function Permit.new(semaphore)
- return setmetatable({ semaphore = semaphore }, Permit)
+function Permit:new(semaphore)
+ ---@type Permit
+ local instance = {}
+ setmetatable(instance, self)
+ instance.semaphore = semaphore
+ return instance
end
function Permit:forget()
@@ -42,7 +50,7 @@ function Permit:forget()
if semaphore.permits > 0 and #semaphore.handles > 0 then
semaphore.permits = semaphore.permits - 1
local release = table.remove(semaphore.handles, 1)
- release(Permit.new(semaphore))
+ release(Permit:new(semaphore))
end
end
@@ -51,8 +59,13 @@ local Semaphore = {}
Semaphore.__index = Semaphore
---@param permits integer
-function Semaphore.new(permits)
- return setmetatable({ permits = permits, handles = {} }, Semaphore)
+function Semaphore:new(permits)
+ ---@type Semaphore
+ local instance = {}
+ setmetatable(instance, self)
+ instance.permits = permits
+ instance.handles = {}
+ return instance
end
---@async
@@ -65,7 +78,7 @@ function Semaphore:acquire()
end)
end
- return Permit.new(self)
+ return Permit:new(self)
end
---@class OneShotChannel
@@ -75,12 +88,14 @@ end
local OneShotChannel = {}
OneShotChannel.__index = OneShotChannel
-function OneShotChannel.new()
- return setmetatable({
- has_sent = false,
- value = nil,
- condvar = Condvar.new(),
- }, OneShotChannel)
+function OneShotChannel:new()
+ ---@type OneShotChannel
+ local instance = {}
+ setmetatable(instance, self)
+ instance.has_sent = false
+ instance.value = nil
+ instance.condvar = Condvar:new()
+ return instance
end
function OneShotChannel:is_closed()
@@ -108,12 +123,15 @@ end
---@field is_closed boolean
local Channel = {}
Channel.__index = Channel
-function Channel.new()
- return setmetatable({
- condvar = Condvar.new(),
- buffer = nil,
- is_closed = false,
- }, Channel)
+
+function Channel:new()
+ ---@type Channel
+ local instance = {}
+ setmetatable(instance, self)
+ instance.condvar = Condvar:new()
+ instance.buffer = nil
+ instance.is_closed = false
+ return instance
end
function Channel:close()
diff --git a/lua/mason-core/async/init.lua b/lua/mason-core/async/init.lua
index 63d4ec94..56d86170 100644
--- a/lua/mason-core/async/init.lua
+++ b/lua/mason-core/async/init.lua
@@ -6,8 +6,12 @@ local exports = {}
local Promise = {}
Promise.__index = Promise
-function Promise.new(resolver)
- return setmetatable({ resolver = resolver, has_resolved = false }, Promise)
+function Promise:new(resolver)
+ local instance = {}
+ setmetatable(instance, self)
+ instance.resolver = resolver
+ instance.has_resolved = false
+ return instance
end
---@param success boolean
@@ -27,7 +31,7 @@ function Promise:__call(callback)
end
local function await(resolver)
- local ok, value = co.yield(Promise.new(resolver))
+ local ok, value = co.yield(Promise:new(resolver))
if not ok then
error(value[1], 0)
end
@@ -156,7 +160,7 @@ end
---@param suspend_fns async fun()[]
---@param mode '"first"' | '"all"'
local function wait(suspend_fns, mode)
- local channel = require("mason-core.async.control").OneShotChannel.new()
+ local channel = require("mason-core.async.control").OneShotChannel:new()
if #suspend_fns == 0 then
return
end
diff --git a/lua/mason-core/installer/context/cwd.lua b/lua/mason-core/installer/context/cwd.lua
index cb2e70ec..2b74bf55 100644
--- a/lua/mason-core/installer/context/cwd.lua
+++ b/lua/mason-core/installer/context/cwd.lua
@@ -11,13 +11,15 @@ InstallContextCwd.__index = InstallContextCwd
---@param handle InstallHandle
---@param location InstallLocation
-function InstallContextCwd.new(handle, location)
+function InstallContextCwd:new(handle, location)
assert(location, "location not provided")
- return setmetatable({
- location = location,
- handle = handle,
- cwd = nil,
- }, InstallContextCwd)
+ ---@type InstallContextCwd
+ local instance = {}
+ setmetatable(instance, self)
+ instance.location = location
+ instance.handle = handle
+ instance.cwd = nil
+ return instance
end
function InstallContextCwd:initialize()
diff --git a/lua/mason-core/installer/context/fs.lua b/lua/mason-core/installer/context/fs.lua
index 5c51fb56..93379017 100644
--- a/lua/mason-core/installer/context/fs.lua
+++ b/lua/mason-core/installer/context/fs.lua
@@ -8,8 +8,12 @@ local InstallContextFs = {}
InstallContextFs.__index = InstallContextFs
---@param cwd InstallContextCwd
-function InstallContextFs.new(cwd)
- return setmetatable({ cwd = cwd }, InstallContextFs)
+function InstallContextFs:new(cwd)
+ ---@type InstallContextFs
+ local instance = {}
+ setmetatable(instance, InstallContextFs)
+ instance.cwd = cwd
+ return instance
end
---@async
diff --git a/lua/mason-core/installer/context/init.lua b/lua/mason-core/installer/context/init.lua
index f2cedb42..425bf39c 100644
--- a/lua/mason-core/installer/context/init.lua
+++ b/lua/mason-core/installer/context/init.lua
@@ -26,10 +26,10 @@ InstallContext.__index = InstallContext
---@param handle InstallHandle
---@param location InstallLocation
---@param opts PackageInstallOpts
-function InstallContext.new(handle, location, opts)
- local cwd = InstallContextCwd.new(handle, location)
- local spawn = InstallContextSpawn.new(handle, cwd, false)
- local fs = InstallContextFs.new(cwd)
+function InstallContext:new(handle, location, opts)
+ local cwd = InstallContextCwd:new(handle, location)
+ local spawn = InstallContextSpawn:new(handle, cwd, false)
+ local fs = InstallContextFs:new(cwd)
return setmetatable({
cwd = cwd,
spawn = spawn,
@@ -37,7 +37,7 @@ function InstallContext.new(handle, location, opts)
location = location,
package = handle.package, -- for convenience
fs = fs,
- receipt = receipt.InstallReceiptBuilder.new(),
+ receipt = receipt.InstallReceiptBuilder:new(),
stdio_sink = handle.stdio.sink,
links = {
bin = {},
diff --git a/lua/mason-core/installer/context/spawn.lua b/lua/mason-core/installer/context/spawn.lua
index 0a73ff3a..f2ce8df2 100644
--- a/lua/mason-core/installer/context/spawn.lua
+++ b/lua/mason-core/installer/context/spawn.lua
@@ -10,8 +10,14 @@ local InstallContextSpawn = {}
---@param handle InstallHandle
---@param cwd InstallContextCwd
---@param strict_mode boolean
-function InstallContextSpawn.new(handle, cwd, strict_mode)
- return setmetatable({ cwd = cwd, handle = handle, strict_mode = strict_mode }, InstallContextSpawn)
+function InstallContextSpawn:new(handle, cwd, strict_mode)
+ ---@type InstallContextSpawn
+ local instance = {}
+ setmetatable(instance, self)
+ instance.cwd = cwd
+ instance.handle = handle
+ instance.strict_mode = strict_mode
+ return instance
end
---@param cmd string
diff --git a/lua/mason-core/installer/handle.lua b/lua/mason-core/installer/handle.lua
index 96acbdd1..62da5bae 100644
--- a/lua/mason-core/installer/handle.lua
+++ b/lua/mason-core/installer/handle.lua
@@ -23,9 +23,19 @@ local uv = vim.loop
local InstallHandleSpawnHandle = {}
InstallHandleSpawnHandle.__index = InstallHandleSpawnHandle
----@param fields InstallHandleSpawnHandle
-function InstallHandleSpawnHandle.new(fields)
- return setmetatable(fields, InstallHandleSpawnHandle)
+---@param luv_handle luv_handle
+---@param pid integer
+---@param cmd string
+---@param args string[]
+function InstallHandleSpawnHandle:new(luv_handle, pid, cmd, args)
+ ---@type InstallHandleSpawnHandle
+ local instance = {}
+ setmetatable(instance, InstallHandleSpawnHandle)
+ instance.uv_handle = luv_handle
+ instance.pid = pid
+ instance.cmd = cmd
+ instance.args = args
+ return instance
end
function InstallHandleSpawnHandle:__tostring()
@@ -38,8 +48,9 @@ end
---@field stdio { buffers: { stdout: string[], stderr: string[] }, sink: StdioSink }
---@field is_terminated boolean
---@field private spawn_handles InstallHandleSpawnHandle[]
-local InstallHandle = setmetatable({}, { __index = EventEmitter })
-local InstallHandleMt = { __index = InstallHandle }
+local InstallHandle = {}
+InstallHandle.__index = InstallHandle
+setmetatable(InstallHandle, { __index = EventEmitter })
---@param handle InstallHandle
local function new_sink(handle)
@@ -60,14 +71,14 @@ local function new_sink(handle)
end
---@param pkg Package
-function InstallHandle.new(pkg)
- local self = EventEmitter.init(setmetatable({}, InstallHandleMt))
- self.state = "IDLE"
- self.package = pkg
- self.spawn_handles = {}
- self.stdio = new_sink(self)
- self.is_terminated = false
- return self
+function InstallHandle:new(pkg)
+ local instance = EventEmitter.new(self)
+ instance.state = "IDLE"
+ instance.package = pkg
+ instance.spawn_handles = {}
+ instance.stdio = new_sink(instance)
+ instance.is_terminated = false
+ return instance
end
---@param luv_handle luv_handle
@@ -75,12 +86,7 @@ end
---@param cmd string
---@param args string[]
function InstallHandle:register_spawn_handle(luv_handle, pid, cmd, args)
- local spawn_handles = InstallHandleSpawnHandle.new {
- uv_handle = luv_handle,
- pid = pid,
- cmd = cmd,
- args = args,
- }
+ local spawn_handles = InstallHandleSpawnHandle:new(luv_handle, pid, cmd, args)
log.fmt_trace("Pushing spawn_handles stack for %s: %s (pid: %s)", self, spawn_handles, pid)
self.spawn_handles[#self.spawn_handles + 1] = spawn_handles
self:emit "spawn_handles:change"
@@ -211,7 +217,7 @@ function InstallHandle:close()
self:__clear_event_handlers()
end
-function InstallHandleMt:__tostring()
+function InstallHandle:__tostring()
return ("InstallHandle(package=%s, state=%s)"):format(self.package, self.state)
end
diff --git a/lua/mason-core/installer/location.lua b/lua/mason-core/installer/location.lua
index cc069cc2..9cdf097f 100644
--- a/lua/mason-core/installer/location.lua
+++ b/lua/mason-core/installer/location.lua
@@ -8,14 +8,16 @@ local InstallLocation = {}
InstallLocation.__index = InstallLocation
---@param dir string
-function InstallLocation.new(dir)
- return setmetatable({
- dir = dir,
- }, InstallLocation)
+function InstallLocation:new(dir)
+ ---@type InstallLocation
+ local instance = {}
+ setmetatable(instance, self)
+ instance.dir = dir
+ return instance
end
function InstallLocation.global()
- return InstallLocation.new(settings.current.install_root_dir)
+ return InstallLocation:new(settings.current.install_root_dir)
end
function InstallLocation:get_dir()
diff --git a/lua/mason-core/installer/runner.lua b/lua/mason-core/installer/runner.lua
index 3e3580e5..64aa605d 100644
--- a/lua/mason-core/installer/runner.lua
+++ b/lua/mason-core/installer/runner.lua
@@ -20,12 +20,14 @@ InstallRunner.__index = InstallRunner
---@param location InstallLocation
---@param handle InstallHandle
---@param semaphore Semaphore
-function InstallRunner.new(location, handle, semaphore)
- return setmetatable({
- location = location,
- semaphore = semaphore,
- handle = handle,
- }, InstallRunner)
+function InstallRunner:new(location, handle, semaphore)
+ ---@type InstallRunner
+ local instance = {}
+ setmetatable(instance, self)
+ instance.location = location
+ instance.semaphore = semaphore
+ instance.handle = handle
+ return instance
end
---@param opts PackageInstallOpts
@@ -34,7 +36,7 @@ function InstallRunner:execute(opts, callback)
local handle = self.handle
log.fmt_info("Executing installer for %s %s", handle.package, opts)
- local context = InstallContext.new(handle, self.location, opts)
+ local context = InstallContext:new(handle, self.location, opts)
local tailed_output = {}
diff --git a/lua/mason-core/optional.lua b/lua/mason-core/optional.lua
index d5055c9c..bb168324 100644
--- a/lua/mason-core/optional.lua
+++ b/lua/mason-core/optional.lua
@@ -4,18 +4,22 @@ local Optional = {}
Optional.__index = Optional
---@param value any
-function Optional.new(value)
- return setmetatable({ _value = value }, Optional)
+function Optional:new(value)
+ ---@type Optional
+ local instance = {}
+ setmetatable(instance, self)
+ instance._value = value
+ return instance
end
-local EMPTY = Optional.new(nil)
+local EMPTY = Optional:new(nil)
---@param value any
function Optional.of_nilable(value)
if value == nil then
return EMPTY
else
- return Optional.new(value)
+ return Optional:new(value)
end
end
@@ -25,7 +29,7 @@ end
---@param value any
function Optional.of(value)
- return Optional.new(value)
+ return Optional:new(value)
end
---@param mapper_fn fun(value: any): any
diff --git a/lua/mason-core/package.lua b/lua/mason-core/package.lua
index 58ad9b46..a8a7ac79 100644
--- a/lua/mason-core/package.lua
+++ b/lua/mason-core/package.lua
@@ -17,7 +17,9 @@ local Semaphore = require("mason-core.async.control").Semaphore
---@field name string
---@field spec RegistryPackageSpec
---@field private handle InstallHandle The currently associated handle.
-local Package = setmetatable({}, { __index = EventEmitter })
+local Package = {}
+Package.__index = Package
+setmetatable(Package, { __index = EventEmitter })
---@param package_identifier string
---@return string, string?
@@ -56,8 +58,6 @@ Package.License = setmetatable({}, {
end,
})
-local PackageMt = { __index = Package }
-
---@class RegistryPackageSourceVersionOverride : RegistryPackageSource
---@field constraint string
@@ -108,12 +108,12 @@ local function validate_spec(spec)
end
---@param spec RegistryPackageSpec
-function Package.new(spec)
+function Package:new(spec)
validate_spec(spec)
- return EventEmitter.init(setmetatable({
- name = spec.name, -- for convenient access
- spec = spec,
- }, PackageMt))
+ local instance = EventEmitter.new(self) --[[@as Package]]
+ instance.name = spec.name -- for convenient access
+ instance.spec = spec
+ return instance
end
function Package:new_handle()
@@ -122,7 +122,7 @@ function Package:new_handle()
end)
log.fmt_trace("Creating new handle for %s", self)
local InstallationHandle = require "mason-core.installer.handle"
- local handle = InstallationHandle.new(self)
+ local handle = InstallationHandle:new(self)
self.handle = handle
-- Ideally we'd decouple this and leverage Mason's event system, but to allow loading as little as possible during
@@ -139,7 +139,7 @@ end
---@alias PackageInstallOpts { version?: string, debug?: boolean, target?: string, force?: boolean, strict?: boolean }
-- TODO this needs to be elsewhere
-local semaphore = Semaphore.new(settings.current.max_concurrent_installers)
+local semaphore = Semaphore:new(settings.current.max_concurrent_installers)
function Package:is_installing()
return self:get_handle()
@@ -159,7 +159,7 @@ function Package:install(opts, callback)
opts = opts or {}
assert(not self:is_installing(), "Package is already installing.")
local handle = self:new_handle()
- local runner = InstallRunner.new(InstallLocation.global(), handle, semaphore)
+ local runner = InstallRunner:new(InstallLocation.global(), handle, semaphore)
runner:execute(opts, callback)
return handle
end
@@ -263,13 +263,12 @@ function Package:get_lsp_settings_schema()
end
return Optional.empty()
end
-
-function PackageMt.__tostring(self)
- return ("Package(name=%s)"):format(self.name)
-end
-
function Package:get_aliases()
return require("mason-registry").get_package_aliases(self.name)
end
+function Package:__tostring()
+ return ("Package(name=%s)"):format(self.name)
+end
+
return Package
diff --git a/lua/mason-core/receipt.lua b/lua/mason-core/receipt.lua
index 748cab38..63403503 100644
--- a/lua/mason-core/receipt.lua
+++ b/lua/mason-core/receipt.lua
@@ -25,12 +25,12 @@ local M = {}
local InstallReceipt = {}
InstallReceipt.__index = InstallReceipt
-function InstallReceipt.new(data)
- return setmetatable(data, InstallReceipt)
+function InstallReceipt:new(data)
+ return setmetatable(data, self)
end
function InstallReceipt.from_json(json)
- return InstallReceipt.new(json)
+ return InstallReceipt:new(json)
end
function InstallReceipt:get_name()
@@ -72,14 +72,16 @@ end
local InstallReceiptBuilder = {}
InstallReceiptBuilder.__index = InstallReceiptBuilder
-function InstallReceiptBuilder.new()
- return setmetatable({
- links = {
- bin = vim.empty_dict(),
- share = vim.empty_dict(),
- opt = vim.empty_dict(),
- },
- }, InstallReceiptBuilder)
+function InstallReceiptBuilder:new()
+ ---@type InstallReceiptBuilder
+ local instance = {}
+ setmetatable(instance, self)
+ instance.links = {
+ bin = vim.empty_dict(),
+ share = vim.empty_dict(),
+ opt = vim.empty_dict(),
+ }
+ return instance
end
---@param name string
@@ -130,7 +132,7 @@ function InstallReceiptBuilder:build()
assert(self.start_time, "start_time is required")
assert(self.completion_time, "completion_time is required")
assert(self.source, "source is required")
- return InstallReceipt.new {
+ return InstallReceipt:new {
name = self.name,
schema_version = "1.2",
metrics = {
diff --git a/lua/mason-core/result.lua b/lua/mason-core/result.lua
index 1491c31f..e98a11b3 100644
--- a/lua/mason-core/result.lua
+++ b/lua/mason-core/result.lua
@@ -3,8 +3,12 @@
local Failure = {}
Failure.__index = Failure
-function Failure.new(error)
- return setmetatable({ error = error }, Failure)
+function Failure:new(error)
+ ---@type Failure
+ local instance = {}
+ setmetatable(instance, self)
+ instance.error = error
+ return instance
end
---@class Result
@@ -12,18 +16,20 @@ end
local Result = {}
Result.__index = Result
-function Result.new(value)
- return setmetatable({
- value = value,
- }, Result)
+function Result:new(value)
+ ---@type Result
+ local instance = {}
+ setmetatable(instance, self)
+ instance.value = value
+ return instance
end
function Result.success(value)
- return Result.new(value)
+ return Result:new(value)
end
function Result.failure(error)
- return Result.new(Failure.new(error))
+ return Result:new(Failure:new(error))
end
function Result:get_or_nil()
diff --git a/lua/mason-core/ui/display.lua b/lua/mason-core/ui/display.lua
index ebd33203..a9e63910 100644
--- a/lua/mason-core/ui/display.lua
+++ b/lua/mason-core/ui/display.lua
@@ -229,7 +229,7 @@ function M.new_view_only_win(name, filetype)
---@type WindowOpts
local window_opts = {}
- local events = EventEmitter.new()
+ local events = EventEmitter:new()
vim.diagnostic.config({
virtual_text = {
diff --git a/lua/mason-registry/installer.lua b/lua/mason-registry/installer.lua
index 31fe0d85..3fc4fb31 100644
--- a/lua/mason-registry/installer.lua
+++ b/lua/mason-registry/installer.lua
@@ -11,7 +11,7 @@ local update_channel
---@async
function M.run()
if not update_channel or update_channel:is_closed() then
- update_channel = OneShotChannel.new()
+ update_channel = OneShotChannel:new()
a.run(function()
update_channel:send(Result.try(function(try)
local updated_sources = {}
diff --git a/lua/mason-registry/sources/file.lua b/lua/mason-registry/sources/file.lua
index bb53c28d..628b1253 100644
--- a/lua/mason-registry/sources/file.lua
+++ b/lua/mason-registry/sources/file.lua
@@ -23,10 +23,12 @@ local FileRegistrySource = {}
FileRegistrySource.__index = FileRegistrySource
---@param spec FileRegistrySourceSpec
-function FileRegistrySource.new(spec)
- return setmetatable({
- spec = spec,
- }, FileRegistrySource)
+function FileRegistrySource:new(spec)
+ ---@type FileRegistrySource
+ local instance = {}
+ setmetatable(instance, self)
+ instance.spec = spec
+ return instance
end
function FileRegistrySource:is_installed()
diff --git a/lua/mason-registry/sources/github.lua b/lua/mason-registry/sources/github.lua
index 81ccaf56..d0a782fb 100644
--- a/lua/mason-registry/sources/github.lua
+++ b/lua/mason-registry/sources/github.lua
@@ -31,15 +31,17 @@ local GitHubRegistrySource = {}
GitHubRegistrySource.__index = GitHubRegistrySource
---@param spec GitHubRegistrySourceSpec
-function GitHubRegistrySource.new(spec)
+function GitHubRegistrySource:new(spec)
+ ---@type GitHubRegistrySource
+ local instance = {}
+ setmetatable(instance, GitHubRegistrySource)
local root_dir = InstallLocation.global():registry(path.concat { "github", spec.namespace, spec.name })
- return setmetatable({
- id = spec.id,
- spec = spec,
- root_dir = root_dir,
- data_file = path.concat { root_dir, "registry.json" },
- info_file = path.concat { root_dir, "info.json" },
- }, GitHubRegistrySource)
+ instance.id = spec.id
+ instance.spec = spec
+ instance.root_dir = root_dir
+ instance.data_file = path.concat { root_dir, "registry.json" }
+ instance.info_file = path.concat { root_dir, "info.json" }
+ return instance
end
function GitHubRegistrySource:is_installed()
diff --git a/lua/mason-registry/sources/init.lua b/lua/mason-registry/sources/init.lua
index bdaaf38e..af1b9f6a 100644
--- a/lua/mason-registry/sources/init.lua
+++ b/lua/mason-registry/sources/init.lua
@@ -25,7 +25,7 @@ local function parse(registry_id)
local name, version = unpack(vim.split(name, "@"))
return function()
local GitHubRegistrySource = require "mason-registry.sources.github"
- return GitHubRegistrySource.new {
+ return GitHubRegistrySource:new {
id = registry_id,
repo = ("%s/%s"):format(namespace, name),
namespace = namespace,
@@ -36,7 +36,7 @@ local function parse(registry_id)
elseif type == "lua" then
return function()
local LuaRegistrySource = require "mason-registry.sources.lua"
- return LuaRegistrySource.new {
+ return LuaRegistrySource:new {
id = registry_id,
mod = id,
}
@@ -44,7 +44,7 @@ local function parse(registry_id)
elseif type == "file" then
return function()
local FileRegistrySource = require "mason-registry.sources.file"
- return FileRegistrySource.new {
+ return FileRegistrySource:new {
path = id,
}
end
diff --git a/lua/mason-registry/sources/lua.lua b/lua/mason-registry/sources/lua.lua
index 1ca88a8d..fd88a49d 100644
--- a/lua/mason-registry/sources/lua.lua
+++ b/lua/mason-registry/sources/lua.lua
@@ -12,11 +12,13 @@ local LuaRegistrySource = {}
LuaRegistrySource.__index = LuaRegistrySource
---@param spec LuaRegistrySourceSpec
-function LuaRegistrySource.new(spec)
- return setmetatable({
- id = spec.id,
- spec = spec,
- }, LuaRegistrySource)
+function LuaRegistrySource:new(spec)
+ ---@type LuaRegistrySource
+ local instance = {}
+ setmetatable(instance, LuaRegistrySource)
+ instance.id = spec.id
+ instance.spec = spec
+ return instance
end
---@param pkg_name string
diff --git a/lua/mason-registry/sources/util.lua b/lua/mason-registry/sources/util.lua
index 04ab7845..8be07010 100644
--- a/lua/mason-registry/sources/util.lua
+++ b/lua/mason-registry/sources/util.lua
@@ -35,7 +35,7 @@ M.hydrate_package = _.curryN(function(buffer, spec)
pkg.spec = spec
return pkg
end
- return Pkg.new(spec)
+ return Pkg:new(spec)
end, 2)
return M
diff --git a/lua/mason-test/helpers.lua b/lua/mason-test/helpers.lua
index 149589bf..2348e9df 100644
--- a/lua/mason-test/helpers.lua
+++ b/lua/mason-test/helpers.lua
@@ -10,9 +10,9 @@ local M = {}
---@param opts? { install_opts?: PackageInstallOpts, package?: string }
function M.create_context(opts)
local pkg = registry.get_package(opts and opts.package or "dummy")
- local handle = InstallHandle.new(pkg)
+ local handle = InstallHandle:new(pkg)
local location = InstallLocation.global()
- local context = InstallContext.new(handle, location, opts and opts.install_opts or {})
+ local context = InstallContext:new(handle, location, opts and opts.install_opts or {})
context.spawn = setmetatable({}, {
__index = function(s, cmd)
s[cmd] = spy.new(function()
diff --git a/lua/mason/health.lua b/lua/mason/health.lua
index 50fe3a46..42e5f4bd 100644
--- a/lua/mason/health.lua
+++ b/lua/mason/health.lua
@@ -20,7 +20,7 @@ local report_ok = _.scheduler_wrap(health.ok or health.report_ok)
local report_warn = _.scheduler_wrap(health.warn or health.report_warn)
local report_error = _.scheduler_wrap(health.error or health.report_error)
-local sem = Semaphore.new(5)
+local sem = Semaphore:new(5)
---@async
---@param opts {cmd:string, args:string[], name: string, use_stderr: boolean?, version_check: (fun(version: string): string?), relaxed: boolean?, advice: string[]}
diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua
index fb435a4d..ae246887 100644
--- a/lua/mason/ui/instance.lua
+++ b/lua/mason/ui/instance.lua
@@ -490,7 +490,7 @@ local function check_new_visible_package_versions()
end)
end
- local sem = Semaphore.new(5)
+ local sem = Semaphore:new(5)
a.wait_all(_.map(function(pkg)
return function()
local permit = sem:acquire()
diff --git a/tests/helpers/lua/dummy-registry/dummy2_package.lua b/tests/helpers/lua/dummy-registry/dummy2_package.lua
index 793404ea..008d27b2 100644
--- a/tests/helpers/lua/dummy-registry/dummy2_package.lua
+++ b/tests/helpers/lua/dummy-registry/dummy2_package.lua
@@ -1,6 +1,6 @@
local Pkg = require "mason-core.package"
-return Pkg.new {
+return Pkg:new {
schema = "registry+v1",
name = "dummy2",
description = [[This is a dummy2 package.]],
diff --git a/tests/helpers/lua/dummy-registry/dummy_package.lua b/tests/helpers/lua/dummy-registry/dummy_package.lua
index 52a709ad..4fbaf44d 100644
--- a/tests/helpers/lua/dummy-registry/dummy_package.lua
+++ b/tests/helpers/lua/dummy-registry/dummy_package.lua
@@ -1,6 +1,6 @@
local Pkg = require "mason-core.package"
-return Pkg.new {
+return Pkg:new {
schema = "registry+v1",
name = "dummy",
description = [[This is a dummy package.]],
diff --git a/tests/helpers/lua/dummy-registry/registry_package.lua b/tests/helpers/lua/dummy-registry/registry_package.lua
index e72284a8..7e5d9fbd 100644
--- a/tests/helpers/lua/dummy-registry/registry_package.lua
+++ b/tests/helpers/lua/dummy-registry/registry_package.lua
@@ -1,6 +1,6 @@
local Pkg = require "mason-core.package"
-return Pkg.new {
+return Pkg:new {
schema = "registry+v1",
name = "registry",
description = [[This is a dummy package.]],
diff --git a/tests/mason-core/async/async_spec.lua b/tests/mason-core/async/async_spec.lua
index a4197b85..79f74462 100644
--- a/tests/mason-core/async/async_spec.lua
+++ b/tests/mason-core/async/async_spec.lua
@@ -188,7 +188,7 @@ describe("async :: Condvar", function()
local Condvar = control.Condvar
it("should block execution until condvar is notified", function()
- local condvar = Condvar.new()
+ local condvar = Condvar:new()
local function wait()
local start = timestamp()
@@ -222,7 +222,7 @@ describe("async :: Semaphore", function()
local Semaphore = control.Semaphore
it("should limit the amount of permits", function()
- local sem = Semaphore.new(5)
+ local sem = Semaphore:new(5)
---@type Permit[]
local permits = {}
@@ -237,7 +237,7 @@ describe("async :: Semaphore", function()
end)
it("should lease new permits", function()
- local sem = Semaphore.new(2)
+ local sem = Semaphore:new(2)
---@type Permit[]
local permits = {}
@@ -259,7 +259,7 @@ describe("async :: OneShotChannel", function()
local OneShotChannel = control.OneShotChannel
it("should only allow sending once", function()
- local channel = OneShotChannel.new()
+ local channel = OneShotChannel:new()
assert.is_false(channel:is_closed())
channel:send "value"
assert.is_true(channel:is_closed())
@@ -270,7 +270,7 @@ describe("async :: OneShotChannel", function()
end)
it("should wait until it can receive", function()
- local channel = OneShotChannel.new()
+ local channel = OneShotChannel:new()
local start = timestamp()
local value = a.run_blocking(function()
@@ -286,7 +286,7 @@ describe("async :: OneShotChannel", function()
end)
it("should receive immediately if value is already sent", function()
- local channel = OneShotChannel.new()
+ local channel = OneShotChannel:new()
channel:send(42)
assert.equals(42, channel:receive())
end)
@@ -296,7 +296,7 @@ describe("async :: Channel", function()
local Channel = control.Channel
it("should suspend send until buffer is received", function()
- local channel = Channel.new()
+ local channel = Channel:new()
spy.on(channel, "send")
local guard = spy.new()
@@ -312,7 +312,7 @@ describe("async :: Channel", function()
end)
it("should send subsequent messages after they're received", function()
- local channel = Channel.new()
+ local channel = Channel:new()
spy.on(channel, "send")
a.run(function()
@@ -329,7 +329,7 @@ describe("async :: Channel", function()
end)
it("should suspend receive until message is sent", function()
- local channel = Channel.new()
+ local channel = Channel:new()
a.run(function()
a.sleep(100)
diff --git a/tests/mason-core/installer/handle_spec.lua b/tests/mason-core/installer/handle_spec.lua
index 66a9a5c4..780b1cc7 100644
--- a/tests/mason-core/installer/handle_spec.lua
+++ b/tests/mason-core/installer/handle_spec.lua
@@ -15,7 +15,7 @@ describe("installer handle", function()
end)
it("should register spawn handle", function()
- local handle = InstallHandle.new(mock.new {})
+ local handle = InstallHandle:new(mock.new {})
local spawn_handle_change_handler = spy.new()
local luv_handle = mock.new {}
@@ -32,7 +32,7 @@ describe("installer handle", function()
end)
it("should deregister spawn handle", function()
- local handle = InstallHandle.new(mock.new {})
+ local handle = InstallHandle:new(mock.new {})
local spawn_handle_change_handler = spy.new()
local luv_handle1 = mock.new {}
local luv_handle2 = mock.new {}
@@ -53,7 +53,7 @@ describe("installer handle", function()
end)
it("should change state", function()
- local handle = InstallHandle.new(mock.new {})
+ local handle = InstallHandle:new(mock.new {})
local state_change_handler = spy.new()
handle:once("state:change", state_change_handler)
@@ -68,7 +68,7 @@ describe("installer handle", function()
local process = require "mason-core.process"
stub(process, "kill")
local uv_handle = {}
- local handle = InstallHandle.new(mock.new {})
+ local handle = InstallHandle:new(mock.new {})
local kill_handler = spy.new()
handle:once("kill", kill_handler)
@@ -87,7 +87,7 @@ describe("installer handle", function()
stub(process, "kill")
local uv_handle1 = {}
local uv_handle2 = {}
- local handle = InstallHandle.new(mock.new {})
+ local handle = InstallHandle:new(mock.new {})
local kill_handler = spy.new()
local terminate_handler = spy.new()
local closed_handler = spy.new()
diff --git a/tests/mason-core/installer/runner_spec.lua b/tests/mason-core/installer/runner_spec.lua
index 69661842..f4acdcc1 100644
--- a/tests/mason-core/installer/runner_spec.lua
+++ b/tests/mason-core/installer/runner_spec.lua
@@ -30,11 +30,11 @@ describe("install runner ::", function()
describe("locking ::", function()
it("should respect semaphore locks", function()
- local semaphore = Semaphore.new(1)
+ local semaphore = Semaphore:new(1)
local location = InstallLocation.global()
- local dummy_handle = InstallHandle.new(dummy)
- local runner_1 = InstallRunner.new(location, dummy_handle, semaphore)
- local runner_2 = InstallRunner.new(location, InstallHandle.new(dummy2), semaphore)
+ local dummy_handle = InstallHandle:new(dummy)
+ local runner_1 = InstallRunner:new(location, dummy_handle, semaphore)
+ local runner_2 = InstallRunner:new(location, InstallHandle:new(dummy2), semaphore)
stub(dummy.spec.source, "install", function()
a.sleep(10000)
@@ -57,10 +57,10 @@ describe("install runner ::", function()
end)
it("should write lockfile", function()
- local semaphore = Semaphore.new(1)
+ local semaphore = Semaphore:new(1)
local location = InstallLocation.global()
- local dummy_handle = InstallHandle.new(dummy)
- local runner = InstallRunner.new(location, dummy_handle, semaphore)
+ local dummy_handle = InstallHandle:new(dummy)
+ local runner = InstallRunner:new(location, dummy_handle, semaphore)
spy.on(fs.async, "write_file")
@@ -72,10 +72,10 @@ describe("install runner ::", function()
end)
it("should abort installation if installation lock exists", function()
- local semaphore = Semaphore.new(1)
+ local semaphore = Semaphore:new(1)
local location = InstallLocation.global()
- local dummy_handle = InstallHandle.new(dummy)
- local runner = InstallRunner.new(location, dummy_handle, semaphore)
+ local dummy_handle = InstallHandle:new(dummy)
+ local runner = InstallRunner:new(location, dummy_handle, semaphore)
stub(fs.async, "file_exists")
stub(fs.async, "read_file")
@@ -95,10 +95,10 @@ describe("install runner ::", function()
end)
it("should not abort installation if installation lock exists with force=true", function()
- local semaphore = Semaphore.new(1)
+ local semaphore = Semaphore:new(1)
local location = InstallLocation.global()
- local dummy_handle = InstallHandle.new(dummy)
- local runner = InstallRunner.new(location, dummy_handle, semaphore)
+ local dummy_handle = InstallHandle:new(dummy)
+ local runner = InstallRunner:new(location, dummy_handle, semaphore)
stub(fs.async, "file_exists")
stub(fs.async, "read_file")
@@ -115,10 +115,10 @@ describe("install runner ::", function()
end)
it("should release lock after successful installation", function()
- local semaphore = Semaphore.new(1)
+ local semaphore = Semaphore:new(1)
local location = InstallLocation.global()
- local dummy_handle = InstallHandle.new(dummy)
- local runner = InstallRunner.new(location, dummy_handle, semaphore)
+ local dummy_handle = InstallHandle:new(dummy)
+ local runner = InstallRunner:new(location, dummy_handle, semaphore)
local callback = spy.new()
runner:execute({}, callback)
@@ -135,7 +135,7 @@ describe("install runner ::", function()
it("should initialize install location", function()
local location = InstallLocation.global()
- local runner = InstallRunner.new(location, InstallHandle.new(registry.get_package "dummy"), Semaphore.new(1))
+ local runner = InstallRunner:new(location, InstallHandle:new(registry.get_package "dummy"), Semaphore:new(1))
spy.on(location, "initialize")
@@ -150,7 +150,7 @@ describe("install runner ::", function()
it("should write receipt", function()
local location = InstallLocation.global()
local runner =
- InstallRunner.new(location, InstallHandle.new(registry.get_package "dummy"), Semaphore.new(1))
+ InstallRunner:new(location, InstallHandle:new(registry.get_package "dummy"), Semaphore:new(1))
runner:execute {}
@@ -185,8 +185,8 @@ describe("install runner ::", function()
dummy:once("install:failed", package_spy)
local location = InstallLocation.global()
- local handle = InstallHandle.new(registry.get_package "dummy")
- local runner = InstallRunner.new(location, handle, Semaphore.new(1))
+ local handle = InstallHandle:new(registry.get_package "dummy")
+ local runner = InstallRunner:new(location, handle, Semaphore:new(1))
stub(dummy.spec.source, "install", function()
error("I've made a mistake.", 0)
@@ -208,8 +208,8 @@ describe("install runner ::", function()
it("should terminate installation", function()
local location = InstallLocation.global()
- local handle = InstallHandle.new(registry.get_package "dummy")
- local runner = InstallRunner.new(location, handle, Semaphore.new(1))
+ local handle = InstallHandle:new(registry.get_package "dummy")
+ local runner = InstallRunner:new(location, handle, Semaphore:new(1))
local capture = spy.new()
stub(dummy.spec.source, "install", function()
@@ -233,8 +233,8 @@ describe("install runner ::", function()
it("should write debug logs when debug=true", function()
local location = InstallLocation.global()
- local handle = InstallHandle.new(registry.get_package "dummy")
- local runner = InstallRunner.new(location, handle, Semaphore.new(1))
+ local handle = InstallHandle:new(registry.get_package "dummy")
+ local runner = InstallRunner:new(location, handle, Semaphore:new(1))
stub(dummy.spec.source, "install", function(ctx)
ctx.stdio_sink.stdout "Hello "
@@ -254,8 +254,8 @@ describe("install runner ::", function()
it("should not retain installation directory on failure", function()
local location = InstallLocation.global()
- local handle = InstallHandle.new(registry.get_package "dummy")
- local runner = InstallRunner.new(location, handle, Semaphore.new(1))
+ local handle = InstallHandle:new(registry.get_package "dummy")
+ local runner = InstallRunner:new(location, handle, Semaphore:new(1))
stub(dummy.spec.source, "install", function(ctx)
ctx.stdio_sink.stderr "Something will go terribly wrong.\n"
@@ -275,8 +275,8 @@ describe("install runner ::", function()
it("should retain installation directory on failure and debug=true", function()
local location = InstallLocation.global()
- local handle = InstallHandle.new(registry.get_package "dummy")
- local runner = InstallRunner.new(location, handle, Semaphore.new(1))
+ local handle = InstallHandle:new(registry.get_package "dummy")
+ local runner = InstallRunner:new(location, handle, Semaphore:new(1))
stub(dummy.spec.source, "install", function(ctx)
ctx.stdio_sink.stderr "Something will go terribly wrong.\n"
diff --git a/tests/mason-core/package/package_spec.lua b/tests/mason-core/package/package_spec.lua
index 622a2ee4..b9b15d04 100644
--- a/tests/mason-core/package/package_spec.lua
+++ b/tests/mason-core/package/package_spec.lua
@@ -55,35 +55,35 @@ describe("package", function()
assert.equals(
"name: expected string, got number",
assert.has_error(function()
- Pkg.new(spec { name = 23 })
+ Pkg:new(spec { name = 23 })
end)
)
assert.equals(
"description: expected string, got number",
assert.has_error(function()
- Pkg.new(spec { description = 23 })
+ Pkg:new(spec { description = 23 })
end)
)
assert.equals(
"homepage: expected string, got number",
assert.has_error(function()
- Pkg.new(spec { homepage = 23 })
+ Pkg:new(spec { homepage = 23 })
end)
)
assert.equals(
"categories: expected table, got number",
assert.has_error(function()
- Pkg.new(spec { categories = 23 })
+ Pkg:new(spec { categories = 23 })
end)
)
assert.equals(
"languages: expected table, got number",
assert.has_error(function()
- Pkg.new(spec { languages = 23 })
+ Pkg:new(spec { languages = 23 })
end)
)
end)
@@ -211,7 +211,7 @@ describe("package", function()
assert.is_true(vim.in_fast_event())
local pkg = assert.is_not.has_error(function()
- return Pkg.new(dummy.spec)
+ return Pkg:new(dummy.spec)
end)
assert.same(dummy.spec, pkg.spec)
end)
diff --git a/tests/mason-core/receipt_spec.lua b/tests/mason-core/receipt_spec.lua
index 05ce1439..e7fcd648 100644
--- a/tests/mason-core/receipt_spec.lua
+++ b/tests/mason-core/receipt_spec.lua
@@ -7,7 +7,7 @@ end
describe("receipt ::", function()
it("should parse 1.0 structures", function()
- local receipt = InstallReceipt.new(fixture "1.0.json")
+ local receipt = InstallReceipt:new(fixture "1.0.json")
assert.equals("angular-language-server", receipt:get_name())
assert.equals("1.0", receipt:get_schema_version())
@@ -21,7 +21,7 @@ describe("receipt ::", function()
end)
it("should parse 1.1 structures", function()
- local receipt = InstallReceipt.new(fixture "1.1.json")
+ local receipt = InstallReceipt:new(fixture "1.1.json")
assert.equals("angular-language-server", receipt:get_name())
assert.equals("1.1", receipt:get_schema_version())
@@ -46,7 +46,7 @@ describe("receipt ::", function()
end)
it("should parse 1.2 structures", function()
- local receipt = InstallReceipt.new(fixture "1.2.json")
+ local receipt = InstallReceipt:new(fixture "1.2.json")
assert.equals("angular-language-server", receipt:get_name())
assert.equals("1.2", receipt:get_schema_version())
@@ -66,9 +66,9 @@ describe("receipt ::", function()
describe("schema versions ::", function()
it("should check minimum compatibility", function()
- local receipt_1_0 = InstallReceipt.new { schema_version = "1.0" }
- local receipt_1_1 = InstallReceipt.new { schema_version = "1.1" }
- local receipt_1_2 = InstallReceipt.new { schema_version = "1.2" }
+ local receipt_1_0 = InstallReceipt:new { schema_version = "1.0" }
+ local receipt_1_1 = InstallReceipt:new { schema_version = "1.1" }
+ local receipt_1_2 = InstallReceipt:new { schema_version = "1.2" }
assert.is_true(receipt_1_0:is_schema_min "1.0")
assert.is_true(receipt_1_1:is_schema_min "1.0")
diff --git a/tests/mason-registry/sources/lua_spec.lua b/tests/mason-registry/sources/lua_spec.lua
index 27a351d7..c720ae10 100644
--- a/tests/mason-registry/sources/lua_spec.lua
+++ b/tests/mason-registry/sources/lua_spec.lua
@@ -6,7 +6,7 @@ describe("Lua registry source", function()
["my-pkg"] = "pkg-index.my-pkg",
}
package.loaded["pkg-index.my-pkg"] = {}
- local source = LuaRegistrySource.new {
+ local source = LuaRegistrySource:new {
mod = "pkg-index",
}
assert.is_not_nil(source:get_package "my-pkg")
@@ -19,7 +19,7 @@ describe("Lua registry source", function()
["rust-analyzer"] = "pkg-index.rust-analyzer",
["typescript-language-server"] = "pkg-index.typescript-language-server",
}
- local source = LuaRegistrySource.new {
+ local source = LuaRegistrySource:new {
mod = "pkg-index",
}
local package_names = source:get_all_package_names()
@@ -33,10 +33,10 @@ describe("Lua registry source", function()
it("should check if is installed", function()
package.loaded["pkg-index"] = {}
- local installed_source = LuaRegistrySource.new {
+ local installed_source = LuaRegistrySource:new {
mod = "pkg-index",
}
- local uninstalled_source = LuaRegistrySource.new {
+ local uninstalled_source = LuaRegistrySource:new {
mod = "non-existent",
}
@@ -45,6 +45,6 @@ describe("Lua registry source", function()
end)
it("should stringify instances", function()
- assert.equals("LuaRegistrySource(mod=pkg-index)", tostring(LuaRegistrySource.new { mod = "pkg-index" }))
+ assert.equals("LuaRegistrySource(mod=pkg-index)", tostring(LuaRegistrySource:new { mod = "pkg-index" }))
end)
end)