From 086cbe2a095b52bf44f2ac5e361152cb8e77dc1b Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 3 Nov 2022 20:26:54 -0400 Subject: Added conflicts. --- SPEC.md | 4 ++++ src/lpm.lua | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/SPEC.md b/SPEC.md index e48991d..70f7531 100644 --- a/SPEC.md +++ b/SPEC.md @@ -46,7 +46,11 @@ The vast majority of plugins are `singleton` plugins. this plugin provides. Can be used as a dependency. * `dependencies`: Optionally a hash of dependencies required, or optional for this plugin. +* `conflicts`: An optional hash of plugins which conflict with this one, in the same + format as `dependencies`. * `tags`: Optional freeform tags that may describe attributes of the plugin. +* `path`: Optional path to the plugin. If omitted, will only pull the files in + `files`. To pull the whole repository, use `"."`. ### Dependencies diff --git a/src/lpm.lua b/src/lpm.lua index 4dc1c01..8dfc8d8 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -508,6 +508,7 @@ function Plugin.new(repository, metadata) remote = nil, version = "1.0", dependencies = {}, + conflicts = {}, local_path = repository and (repository.local_path .. PATHSEP .. (repository.commit or repository.branch) .. (metadata.path and (PATHSEP .. metadata.path:gsub("^/", "")) or "")), }, metadata), Plugin) self.type = type @@ -526,7 +527,10 @@ end function Plugin:is_core(bottle) return self.type == "core" end function Plugin:is_bundled(bottle) return self.type == "bundled" end function Plugin:is_installed(bottle) return self:is_core(bottle) or (bottle.lite_xl:is_compatible(self) and system.stat(self:get_install_path(bottle))) end -function Plugin:is_incompatible(plugin) return self.dependencies[plugin.name] and not match_version(plugin.version, self.dependencies[plugin.name]) end +function Plugin:is_incompatible(plugin) + return (self.dependencies[plugin.name] and not match_version(plugin.version, self.dependencies[plugin.name] and self.dependencies[plugin.name].version)) or + (self.conflicts[plugin.name] and match_version(plugin.version, self.conflicts[plugin.name] and self.conflicts[plugin.name].version)) +end function Plugin:get_path(bottle) return self:is_installed(bottle) and self:get_install_path(bottle) or self.local_path -- cgit v1.2.3