diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-01-01 21:01:27 -0500 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-01-01 21:01:27 -0500 |
commit | 7f399adb948d716cbb1ebacab37411fd6cee8db6 (patch) | |
tree | b6a67d9ef76587295568ea76cd137eff6e894297 | |
parent | f6829ebb5730ec0ee2908ec390b04fc28374f88d (diff) | |
download | lite-xl-plugin-manager-7f399adb948d716cbb1ebacab37411fd6cee8db6.tar.gz lite-xl-plugin-manager-7f399adb948d716cbb1ebacab37411fd6cee8db6.zip |
Better diagnostics, made it so that we don't crash out if optional dependencies are missing, and ensured that plugins without a path install correctly.
m--------- | lib/libzip | 0 | ||||
-rw-r--r-- | src/lpm.lua | 17 |
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/libzip b/lib/libzip -Subproject 3286a930a11fd046ee268671df2d9d0a3e0ca7e +Subproject 46cafac76bc1f1628b91ac205bf8fa36718bdd1 diff --git a/src/lpm.lua b/src/lpm.lua index fa88dbd..80cd170 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -646,10 +646,16 @@ function Plugin:install(bottle, installing) if incompatible[plugin] then error("can't install " .. self.name .. ": incompatible with " .. incompatible[plugin][1].name .. ":" .. incompatible[plugin][1].version) end end for plugin, v in pairs(self.dependencies) do - if not compatible[plugin] then error("can't find dependency " .. plugin .. (v.version and (":" .. v.version) or "")) end + if not compatible[plugin] then + if not v.optional then + error("can't find dependency " .. plugin .. (v.version and (":" .. v.version) or "")) + else + log_warning("can't find optional dependency " .. plugin .. (v.version and (":" .. v.version) or "")) + end + end end for plugin, v in pairs(self.dependencies) do - if not compatible[plugin]:is_core(bottle) and not compatible[plugin]:is_installed(bottle) then + if compatible[plugin] and not compatible[plugin]:is_core(bottle) and not compatible[plugin]:is_installed(bottle) then if installing[plugin] then error("circular dependency detected in " .. self.name .. ": requires " .. plugin .. " but, " .. plugin .. " requires " .. self.name) end @@ -668,7 +674,6 @@ function Plugin:install(bottle, installing) if self.organization == "complex" and self.path and system.stat(self.local_path).type ~= "dir" then common.mkdirp(install_path) end if self.url then - log_action("Downloading file " .. self.url .. "...") local path = temporary_install_path .. (self.organization == 'complex' and self.path and system.stat(self.local_path).type ~= "dir" and (PATHSEP .. "init.lua") or "") common.get(self.url, path, self.checksum, write_progress_bar) log_action("Downloaded file " .. self.url .. " to " .. path) @@ -686,7 +691,7 @@ function Plugin:install(bottle, installing) log_action("Copying " .. self.local_path .. " to " .. path) common.copy(self.local_path, temporary_path) elseif self.organization == 'complex' then - common.mkdirp(temporary_install_path) + common.copy(self.local_path, temporary_install_path) end for i,file in ipairs(self.files or {}) do if not file.arch or file.arch == ARCH then @@ -694,9 +699,7 @@ function Plugin:install(bottle, installing) if not file.checksum then error("requires a checksum") end local path = install_path .. PATHSEP .. (file.path or common.basename(file.url)) local temporary_path = temporary_install_path .. PATHSEP .. (file.path or common.basename(file.url)) - log_action("Downloading file " .. file.url .. "...") common.get(file.url, temporary_path, file.checksum, write_progress_bar) - log_action("Downloaded file " .. file.url .. " to " .. path) local basename = common.basename(path) if basename:find("%.zip$") or basename:find("%.tar%.gz$") then log_action("Extracting file " .. basename .. " in " .. install_path) @@ -1331,7 +1334,7 @@ local function lpm_install(...) lpm_lite_xl_install(version) else local plugins = common.grep({ system_bottle:get_plugin(name, version, { mod_version = system_bottle.lite_xl.mod_version }) }, function(e) return not e:is_installed(system_bottle) end) - if #plugins == 0 then error("can't find plugin " .. name .. " mod-version: " .. (system_bottle.lite_xl.mod_version or 'any')) end + if #plugins == 0 then error("can't find not installed plugin " .. name .. " mod-version: " .. (system_bottle.lite_xl.mod_version or 'any')) end for j,v in ipairs(plugins) do v:install(system_bottle) end end end |