diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2023-06-27 10:26:42 -0400 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2023-06-27 10:26:42 -0400 |
commit | 02586b9fa37bc6ad42bd1e59321bb2334bec6433 (patch) | |
tree | e348a62d8cb87b4914b27bdf6fc1825b53812cb4 /plugins/plugin_manager | |
parent | f69e69b5bb5ecff0bf8154b9aab0e1c8a1dc265e (diff) | |
download | lite-xl-plugin-manager-02586b9fa37bc6ad42bd1e59321bb2334bec6433.tar.gz lite-xl-plugin-manager-02586b9fa37bc6ad42bd1e59321bb2334bec6433.zip |
Fixed some minor bugs, moved json to a library, updated manifest to reflect this.
Diffstat (limited to 'plugins/plugin_manager')
-rw-r--r-- | plugins/plugin_manager/init.lua | 34 | ||||
-rw-r--r-- | plugins/plugin_manager/plugin_view.lua | 10 |
2 files changed, 22 insertions, 22 deletions
diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua index ae8343d..87c2bad 100644 --- a/plugins/plugin_manager/init.lua +++ b/plugins/plugin_manager/init.lua @@ -166,10 +166,10 @@ function PluginManager:refresh(progress) end -function PluginManager:upgrade(progress) +function PluginManager:upgrade(options) local prom = Promise.new() - run({ "update" }, progress):done(function() - run({ "upgrade" }, progress):done(function() + run({ "update" }, options.progress):done(function() + run({ "upgrade" }, options.progress):done(function() prom:resolve() end) end) @@ -178,8 +178,8 @@ end -function PluginManager:purge(progress) - return run({ "purge" }, progress) +function PluginManager:purge(options) + return run({ "purge" }, options.progress) end @@ -195,22 +195,22 @@ function PluginManager:get_addons() return prom end -local function run_stateful_plugin_command(plugin_manager, cmd, arg, progress) +local function run_stateful_plugin_command(plugin_manager, cmd, arg, options) local promise = Promise.new() - run({ cmd, arg }, progress):done(function(result) - if config.plugins.plugin_manager.restart_on_change then + run({ cmd, arg }, options.progress):done(function(result) + if (options.restart == nil and config.plugins.plugin_manager.restart_on_change) or options.restart then command.perform("core:restart") else - plugin_manager:refresh(progress):forward(promise) + plugin_manager:refresh(options):forward(promise) end end) return promise end -function PluginManager:install(addon, progress) return run_stateful_plugin_command(self, "install", addon.id .. (addon.version and (":" .. addon.version) or ""), progress) end -function PluginManager:uninstall(addon, progress) return run_stateful_plugin_command(self, "uninstall", addon.id, progress) end -function PluginManager:reinstall(addon, progress) return run_stateful_plugin_command(self, "reinstall", addon.id, progress) end +function PluginManager:install(addon, options) return run_stateful_plugin_command(self, "install", addon.id .. (addon.version and (":" .. addon.version) or ""), options) end +function PluginManager:uninstall(addon, options) return run_stateful_plugin_command(self, "uninstall", addon.id, options) end +function PluginManager:reinstall(addon, options) return run_stateful_plugin_command(self, "reinstall", addon.id, options) end function PluginManager:get_addon(name_and_version) @@ -245,7 +245,7 @@ command.add(nil, { function(name) PluginManager:get_addon(name):done(function(addon) core.log("Attempting to install plugin " .. name .. "...") - PluginManager:install(addon, PluginManager.view.progress_callback):done(function() + PluginManager:install(addon, { progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully installed plugin " .. addon.id .. ".") end) end):fail(function() @@ -270,7 +270,7 @@ command.add(nil, { function(name) PluginManager:get_addon(name):done(function(addon) core.log("Attempting to uninstall plugin " .. addon.id .. "...") - PluginManager:uninstall(addon, PluginManager.view.progress_callback):done(function() + PluginManager:uninstall(addon, { progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully uninstalled plugin " .. addon.id .. ".") end) end):fail(function() @@ -317,9 +317,9 @@ command.add(nil, { end ) end, - ["plugin-manager:refresh"] = function() PluginManager:refresh(PluginManager.view.progress_callback):done(function() core.log("Successfully refreshed plugin listing.") end) end, - ["plugin-manager:upgrade"] = function() PluginManager:upgrade(PluginManager.view.progress_callback):done(function() core.log("Successfully upgraded installed plugins.") end) end, - ["plugin-manager:purge"] = function() PluginManager:purge(PluginManager.view.progress_callback):done(function() core.log("Successfully purged lpm directory.") end) end, + ["plugin-manager:refresh"] = function() PluginManager:refresh({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully refreshed plugin listing.") end) end, + ["plugin-manager:upgrade"] = function() PluginManager:upgrade({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully upgraded installed plugins.") end) end, + ["plugin-manager:purge"] = function() PluginManager:purge({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully purged lpm directory.") end) end, ["plugin-manager:show"] = function() local node = core.root_view:get_active_node_default() node:add_view(PluginManager.view(PluginManager)) diff --git a/plugins/plugin_manager/plugin_view.lua b/plugins/plugin_manager/plugin_view.lua index 1f16b3c..d223be6 100644 --- a/plugins/plugin_manager/plugin_view.lua +++ b/plugins/plugin_manager/plugin_view.lua @@ -96,7 +96,7 @@ end function PluginView:refresh() self.loading = true - return self.plugin_manager:refresh(self.progress_callback):done(function() + return self.plugin_manager:refresh({ progress = self.progress_callback }):done(function() self.loading = false self.initialized = true self.widths = {} @@ -204,7 +204,7 @@ end function PluginView:install(plugin) self.loading = true - self.plugin_manager:install(plugin, self.progress_callback):done(function() + self.plugin_manager:install(plugin, { progress = self.progress_callback }):done(function() self.loading = false self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil end) @@ -212,7 +212,7 @@ end function PluginView:uninstall(plugin) self.loading = true - self.plugin_manager:uninstall(plugin, self.progress_callback):done(function() + self.plugin_manager:uninstall(plugin, { progress = self.progress_callback }):done(function() self.loading = false self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil end) @@ -221,7 +221,7 @@ end function PluginView:reinstall(plugin) self.loading = true - self.plugin_manager:reinstall(plugin, self.progress_callback):done(function() + self.plugin_manager:reinstall(plugin, { progress = self.progress_callback }):done(function() self.loading = false self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil end) @@ -230,7 +230,7 @@ end function PluginView:upgrade() self.loading = true - return self.plugin_manager:upgrade(self.progress_callback):done(function() + return self.plugin_manager:upgrade({ progress = self.progress_callback }):done(function() self.loading = false self.selected_plugin, plugin_view.selected_plugin_idx = nil, nil end) |