-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmanage
executable file
·51 lines (42 loc) · 1.11 KB
/
manage
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
#!/usr/bin/env lua
local select_bin = function()
local bins = { "docker", "podman" }
for _, bin in ipairs(bins) do
if os.execute("which " .. bin) ~= nil then
return bin
end
end
print("No container engine found, bins are: " .. table.concat(bins, ", "))
os.exit(1)
end
local exec_and_exit = function(cmd)
local status, _ = os.execute(cmd)
os.exit(status)
end
local build_with = function(bin)
exec_and_exit(bin .. " build -t yaml.nvim .")
end
local test_with = function(bin)
for line in io.lines(".github/workflows/tests.yml") do
if string.find(line, "PlenaryBustedDirectory") then
local cleaned = string.gsub(line, "-? run: ", "")
exec_and_exit(bin .. " run -it yaml.nvim " .. cleaned)
end
end
end
local nvim_with = function(bin)
exec_and_exit(bin .. " run -it yaml.nvim")
end
local main = function()
local opts = {}
local bin = select_bin()
local cmds = { build = build_with, test = test_with, nvim = nvim_with }
for cmd, func in pairs(cmds) do
table.insert(opts, cmd)
if cmd == arg[1] then
func(bin)
end
end
print("No command found, options are: " .. table.concat(opts, ", "))
end
main()