Software /
code /
prosody
Diff
core/configmanager.lua @ 3610:2084959d4096
configmanager: Update Include and RunScript directives to support paths relative to the (current!) config file
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 10 Nov 2010 19:50:07 +0000 |
parent | 3609:954b1159f2f3 |
child | 3613:f617718d2221 |
line wrap: on
line diff
--- a/core/configmanager.lua Wed Nov 10 19:46:53 2010 +0000 +++ b/core/configmanager.lua Wed Nov 10 19:50:07 2010 +0000 @@ -145,7 +145,7 @@ env = setmetatable({ Host = true, host = true, VirtualHost = true, Component = true, component = true, - Include = true, include = true, RunScript = dofile }, { + Include = true, include = true, RunScript = true }, { __index = function (t, k) return rawget(_G, k) or function (settings_table) @@ -205,6 +205,7 @@ local f, err = io.open(file); if f then local data = f:read("*a"); + local file = resolve_relative_path(filename:gsub("[^"..path_sep.."]+$", ""), file); local ok, err = parsers.lua.load(data, file); if not ok then error(err:gsub("%[string.-%]", file), 0); end end @@ -213,6 +214,10 @@ end env.include = env.Include; + function env.RunScript(file) + return dofile(resolve_relative_path(filename:gsub("[^"..path_sep.."]+$", ""), file)); + end + local chunk, err = loadstring(data, "@"..filename); if not chunk then