-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.lua
More file actions
52 lines (41 loc) · 1.4 KB
/
template.lua
File metadata and controls
52 lines (41 loc) · 1.4 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
-- d2x common template (appended by pkgindex-build.lua)
package.type = "courses"
package.xpm = {
windows = { ["latest"] = { url = package.repo .. ".git" } },
linux = { ["latest"] = { url = package.repo .. ".git" } },
macosx = { ["latest"] = { url = package.repo .. ".git" } },
}
import("xim.libxpkg.pkginfo")
import("xim.libxpkg.system")
import("xim.libxpkg.log")
-- NOTE: system.rundir() depends on _RUNTIME which is only available
-- inside hook functions (injected before each hook call), so we must
-- NOT call it at top-level / module-load time.
local projectdir = path.filename(package.repo)
local function d2x_projectdir()
return path.join(system.rundir(), package.name)
end
function installed()
return os.isdir(d2x_projectdir())
end
function install()
os.cp(projectdir, pkginfo.install_dir())
os.tryrm(projectdir)
return true
end
function config()
local dest = d2x_projectdir()
if os.isdir(dest) then
log.warn("Course '%s' is already installed at '%s', skipping config", package.name, dest)
return true
end
os.cp(path.join(pkginfo.install_dir(), projectdir), dest)
os.cd(dest)
system.exec("xlings install")
return true
end
function uninstall()
-- TODO: system.rundir() return '' when called from uninstall hook, so we can't reliably find the installed course dir to remove it.
--os.tryrm(d2x_projectdir())
return true
end