-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-master-file.lua
42 lines (39 loc) · 1.36 KB
/
generate-master-file.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
local json = require ("dkjson")
local lfs = require("lfs")
local output = {
}
local function iterateFolder(path)
for file in lfs.dir(path) do
if file ~= "." and file ~= ".." then
local f = path..'/'..file
print ("\t "..f)
local fh = assert(io.open(f, "rb"))
local content = fh:read("*all")
fh:close()
local func, err = load(content)
if func then
local ok, formula = pcall(func)
if ok then
table.insert(output, {
name = formula.name,
description = formula.description,
homepage = formula.homepage,
repository = formula.repository,
authors = formula.authors,
license = formula.license,
target = formula.target,
versions = formula.versions,
stableVersion = formula.stable()
})
else
error("Could not execute formula")
end
else
error("Could not compile formula")
end
end
end
end
iterateFolder("./formula")
local fh = assert(io.open("./masterfile.json", "w"))
fh:write(json.encode(output, { indent = true }))