blob: c11caabb1ab67b4d58237f307fcc933c002e2836 (
plain) (
tree)
|
|
-- generate default cratera path
-- package.path, but every .lua is replaced with .cratera
-- or use an explicit CRATERA_PATH
if os.getenv("CRATERA_DEFAULT_PATH") then
print(string.format("return %q", os.getenv("CRATERA_DEFAULT_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
if arg[1] == "display" then
print(table.concat(path_parts, pathsep))
else
print(string.format("return %q", table.concat(path_parts, pathsep)))
end
|