Added support for a `.lite_project.lua` file in project directory

This commit is contained in:
rxi 2020-05-06 13:29:35 +01:00
parent 7610e1064f
commit 271e5434d0
1 changed files with 15 additions and 1 deletions

View File

@ -103,6 +103,7 @@ function core.init()
command.add_defaults() command.add_defaults()
local got_plugin_error = not core.load_plugins() local got_plugin_error = not core.load_plugins()
local got_user_error = not core.try(require, "user") local got_user_error = not core.try(require, "user")
local got_project_error = not core.load_project_file()
for i = 2, #ARGS do for i = 2, #ARGS do
local filename = ARGS[i] local filename = ARGS[i]
@ -112,7 +113,7 @@ function core.init()
end end
end end
if got_plugin_error or got_user_error then if got_plugin_error or got_user_error or got_project_error then
command.perform("core:open-log") command.perform("core:open-log")
end end
end end
@ -160,6 +161,19 @@ function core.load_plugins()
end end
function core.load_project_file()
local filename = core.project_dir .. "/.lite_project.lua"
if system.get_file_info(filename) then
return core.try(function()
local fn, err = loadfile(filename)
if not fn then error("Error when loading project file:\n\t" .. err) end
fn()
end)
end
return true
end
function core.reload_module(name) function core.reload_module(name)
local old = package.loaded[name] local old = package.loaded[name]
package.loaded[name] = nil package.loaded[name] = nil