-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkgindex-build.lua
More file actions
58 lines (49 loc) · 1.59 KB
/
pkgindex-build.lua
File metadata and controls
58 lines (49 loc) · 1.59 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
52
53
54
55
56
57
58
package = {
-- base info
name = "pkgindex-update",
description = "SCode Package Index Update Tool",
authors = "sunrisepeak",
license = "Apache-2.0",
repo = "https://github.com/openxlings/xim-pkgindex-scode",
-- xim pkg info
type = "auto-config",
namespace = "scode",
xpm = {
windows = { ["latest"] = { }, },
linux = { ["latest"] = { }, },
ubuntu = { ref = "linux" },
archlinux = { ref = "linux" },
manjaro = { ref = "linux" },
},
}
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
-- skip pkgindex-update.lua
if not file:endswith("pkgindex-update.lua") then
-- append template content to the end of the file
cprint("[${green}%d/%d${clear}] scode::%s", built_index_cnt, all_index_cnt, file)
io.writefile(file, io.readfile(file) .. template_content)
else
cprint("[${yellow}%d/%d${clear}] scode::%s (skip)", built_index_cnt, all_index_cnt, file)
end
end
return true
end
function uninstall()
return true
end