diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2012-06-08 05:04:38 +0200 |
commit | 40ea2230d1d494c55d8a2b22e111c4bd29074974 (patch) | |
tree | 28c1bcbab960b28cc27f30e8ab0c04e30f11da2d /tools/migration/prosody-migrator.lua | |
parent | ad7ee8604f2811d3ca3e5adb5faa8c095f4d5999 (diff) | |
download | prosody-40ea2230d1d494c55d8a2b22e111c4bd29074974.tar.gz prosody-40ea2230d1d494c55d8a2b22e111c4bd29074974.zip |
Eliminate direct setfenv usage
Diffstat (limited to 'tools/migration/prosody-migrator.lua')
-rw-r--r-- | tools/migration/prosody-migrator.lua | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/tools/migration/prosody-migrator.lua b/tools/migration/prosody-migrator.lua index 2a8bf1c3..7c933b88 100644 --- a/tools/migration/prosody-migrator.lua +++ b/tools/migration/prosody-migrator.lua @@ -30,16 +30,22 @@ for i = 1, #arg do end table.remove(arg, handled_opts); +if CFG_SOURCEDIR then + package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; + package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; +else + package.path = "../../?.lua;"..package.path + package.cpath = "../../?.so;"..package.cpath +end + +local envloadfile = require "util.envload".envloadfile; + -- Load config file local function loadfilein(file, env) if loadin then return loadin(env, io.open(file):read("*a")); else - local chunk, err = loadfile(file); - if chunk then - setfenv(chunk, env); - end - return chunk, err; + return envloadfile(file, env); end end @@ -59,14 +65,6 @@ end config_chunk(); -if CFG_SOURCEDIR then - package.path = CFG_SOURCEDIR.."/?.lua;"..package.path; - package.cpath = CFG_SOURCEDIR.."/?.so;"..package.cpath; -elseif not package.loaded["util.json"] then - package.path = "../../?.lua;"..package.path - package.cpath = "../../?.so;"..package.cpath -end - local have_err; if #arg > 0 and #arg ~= 2 then have_err = true; |