diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-01-17 19:39:58 -0500 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-01-17 19:39:58 -0500 |
commit | 8ab019fa37c0a4424ce26b444e0255d047cc1bb0 (patch) | |
tree | 74af6afbc4c6d49db9125c4baf86b9023f94bedf | |
parent | 91779e480164811a3123d6e1f409a54b83f54725 (diff) | |
download | lite-xl-plugin-manager-0.9996.tar.gz lite-xl-plugin-manager-0.9996.zip |
Updated tests to include singleton plugins that are called init.lua and do not have a manifest.v0.9996
-rw-r--r-- | src/lpm.lua | 8 | ||||
-rw-r--r-- | t/run.lua | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/lpm.lua b/src/lpm.lua index f81f69c..5572f98 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -586,7 +586,7 @@ function Addon.new(repository, metadata) }, metadata), Addon) self.type = type -- Directory. - self.organization = metadata.organization or (((self.files and #self.files > 0) or self.remote or (not self.path and not self.url) or (self.path and not self.path:find("%.lua$"))) and "complex" or "singleton") + self.organization = metadata.organization or (((self.files and #self.files > 0) or (not self.path and not self.url) or (self.path and not self.path:find("%.lua$"))) and "complex" or "singleton") if not self.local_path and repository then if metadata.remote then local local_path = (Repository.url(metadata.remote).local_path .. (metadata.path and (PATHSEP .. metadata.path:gsub("^/", "")) or "")) @@ -633,7 +633,7 @@ end function Addon:get_install_path(bottle) local folder = self.type == "color" and "colors" or (self.type == "library" and "libraries" or "plugins") - local path = (((self:is_core(bottle) or self:is_bundled()) and bottle.lite_xl.datadir_path) or (bottle.local_path and (bottle.local_path .. PATHSEP .. "user") or USERDIR)) .. PATHSEP .. folder .. PATHSEP .. (self.path and common.basename(self.path):gsub("%.lua$", "") or self.id) + local path = (((self:is_core(bottle) or self:is_bundled()) and bottle.lite_xl.datadir_path) or (bottle.local_path and (bottle.local_path .. PATHSEP .. "user") or USERDIR)) .. PATHSEP .. folder .. PATHSEP .. self.id if self.organization == "singleton" then path = path .. ".lua" end return path end @@ -909,7 +909,7 @@ function Repository:generate_manifest(repo_id) end end if folder == "plugins" or system.stat(path .. PATHSEP .. folder) then - local addon_dir = system.stat(path .. PATHSEP .. folder) and PATHSEP .. folder .. PATHSEP or PATHSEP + local addon_dir = system.stat(path .. PATHSEP .. folder) and PATHSEP .. folder or "" local files = folder == "plugins" and system.stat(path .. PATHSEP .. "init.lua") and { "init.lua" } or system.ls(path .. addon_dir) for i, file in ipairs(files) do if file:find("%.lua$") then @@ -918,7 +918,7 @@ function Repository:generate_manifest(repo_id) if name ~= "init" then local type = folder == "colors" and "color" or (folder == "libraries" and "library" or "plugin") local addon = { description = nil, id = name:lower():gsub("[^a-z0-9%-_]", ""), name = name, mod_version = 3, version = "0.1", path = addon_dir .. file, type = type } - for line in io.lines(path .. addon_dir .. file) do + for line in io.lines(path .. addon_dir .. PATHSEP .. file) do local _, _, mod_version = line:find("%-%-.*mod%-version:%s*(%w+)") if mod_version then addon.mod_version = mod_version end local _, _, required_addon = line:find("require [\"']plugins.([%w_]+)") @@ -32,6 +32,8 @@ local tests = { lpm("install bracketmatch") plugins = lpm("list bracketmatch")["addons"] assert(#plugins == 1) + lpm("install console") + assert_exists(userdir .. "/plugins/console.lua") end, ["02_install_complex"] = function() local plugins = lpm("list plugin_manager")["addons"] @@ -47,7 +49,6 @@ local tests = { assert_not_exists(userdir .. "/plugins/plugin_manager") lpm("install editorconfig") assert_exists(userdir .. "/plugins/editorconfig") - assert_exists(userdir .. "/plugins/editorconfig/init.lua") end, ["03_upgrade_complex"] = function() local actions = lpm("install plugin_manager") @@ -126,6 +127,7 @@ local function run_tests(tests, arg) end table.sort(names) local max_name = 0 + os.execute("rm -rf " .. tmpdir .. "/lpmtest && mkdir -p " .. tmpdir .. "/lpmtest"); for i,k in ipairs(names) do max_name = math.max(max_name, #k) end for i,k in ipairs(names) do local v = tests[k] |