blob: e12e9a8aa10abbbe14e7ff444d2092ccde6b5298 (
plain) (
blame)
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
|
-- generate default cratera path
-- package.path, but every .lua is replaced with .cratera
-- or use an explicit CRATERA_PATH
if os.getenv("DEFAULT_CRATERA_PATH") then
print(string.format("return %q", os.getenv("DEFAULT_CRATERA_PATH")))
return
end
local pathsep = package.config:match("^[^\n]+\n([^\n]+)")
local pathfinder = "[^"..pathsep.."]*"
-- not gonna worry about ".lua.lua" tbh...
local possible_cratera_path = package.path:gsub("%.lua(.)", {[pathsep] = ".cratera" .. pathsep}):gsub("%.lua$",".cratera")
local path_parts = {}
local i = 1
-- path entries to skip based on filename
local INIT_FILE = "init.cratera"
for path_part in possible_cratera_path:gmatch(pathfinder) do
if not path_part:find(INIT_FILE, -#INIT_FILE, true) then
path_parts[i] = path_part
i = i + 1
end
end
print(string.format("return %q", table.concat(path_parts, pathsep)))
|