-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkgindex-build.lua
More file actions
51 lines (42 loc) · 1.34 KB
/
pkgindex-build.lua
File metadata and controls
51 lines (42 loc) · 1.34 KB
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
package = {
spec = "1",
name = "pkgindex-update",
description = "D2X Package Index Update Tool",
authors = {"sunrisepeak"},
licenses = {"Apache-2.0"},
repo = "https://github.com/d2learn/xim-pkgindex-d2x",
type = "auto-config",
xpm = {
windows = { ["latest"] = { } },
linux = { ["latest"] = { } },
},
}
local projectdir = os.scriptdir()
local pkgsdir = path.join(projectdir, "pkgs")
local template = path.join(projectdir, "template.lua")
function installed()
return false
end
function install()
-- git clean -fdx and discard all changes
os.cd(pkgsdir)
os.execv("git", {"clean", "-fdx"})
os.execv("git", {"checkout", "."})
local files = os.files(path.join(pkgsdir, "**.lua"))
local template_content = io.readfile(template)
local built_index_cnt = 0
local all_index_cnt = #files
for _, file in ipairs(files) do
built_index_cnt = built_index_cnt + 1
if not file:endswith("pkgindex-update.lua") then
cprint("[${green}%d/%d${clear}] d2x::%s", built_index_cnt, all_index_cnt, file)
io.writefile(file, io.readfile(file) .. template_content)
else
cprint("[${yellow}%d/%d${clear}] d2x::%s (skip)", built_index_cnt, all_index_cnt, file)
end
end
return true
end
function uninstall()
return true
end