-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdater.lua
57 lines (47 loc) · 1.43 KB
/
updater.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
local toml = require("toml")
local luv = require("luv")
-- Function to read the TOML file
local function read_toml_file(file_path)
local file = io.open(file_path, "r")
if not file then
error("Could not open file: " .. file_path)
end
local content = file:read("*all")
file:close()
-- return toml.parse(content)
return toml.parse(content)
end
-- Function to perform Rocks! update
local function update_plugin(plugin_name)
print("Updating plugin: " .. plugin_name)
local handle = io.popen("Rocks! update " .. plugin_name)
local result = handle:read("*a")
handle:close()
print(result)
end
-- Function to run updates concurrently
local function concurrent_updates(plugins)
local threads = {}
for plugin_name, _ in pairs(plugins) do
local thread = luv.new_thread(update_plugin, plugin_name)
table.insert(threads, thread)
end
for _, thread in ipairs(threads) do
luv.thread_join(thread)
end
end
-- Main function
local function main()
local config = read_toml_file("rocks.toml")
-- Combine all plugin tables (regular plugins and git plugins)
local all_plugins = {}
for section, plugins in pairs(config) do
if section:find("plugins") then
for plugin_name, _ in pairs(plugins) do
print("Adding plugin: " .. plugin_name)
all_plugins[plugin_name] = true
end
end
end
end
main()