Comparison

tools/migration/prosody-migrator.lua @ 7880:1d998891c967

migrator: Remove wrapper around envloadfile since envloadfile does the right thing in a compatible way
author Kim Alvefur <zash@zash.se>
date Thu, 02 Feb 2017 20:11:25 +0100
parent 5776:bd0ff8ae98a8
child 7893:432f721b0fdf
comparison
equal deleted inserted replaced
7879:5d0175d3ecf4 7880:1d998891c967
38 package.cpath = "../../?.so;"..package.cpath 38 package.cpath = "../../?.so;"..package.cpath
39 end 39 end
40 40
41 local envloadfile = require "util.envload".envloadfile; 41 local envloadfile = require "util.envload".envloadfile;
42 42
43 -- Load config file
44 local function loadfilein(file, env)
45 if loadin then
46 return loadin(env, io.open(file):read("*a"));
47 else
48 return envloadfile(file, env);
49 end
50 end
51
52 local config_file = options.config or default_config; 43 local config_file = options.config or default_config;
53 local from_store = arg[1] or "input"; 44 local from_store = arg[1] or "input";
54 local to_store = arg[2] or "output"; 45 local to_store = arg[2] or "output";
55 46
56 config = {}; 47 config = {};
57 local config_env = setmetatable({}, { __index = function(t, k) return function(tbl) config[k] = tbl; end; end }); 48 local config_env = setmetatable({}, { __index = function(t, k) return function(tbl) config[k] = tbl; end; end });
58 local config_chunk, err = loadfilein(config_file, config_env); 49 local config_chunk, err = envloadfile(config_file, config_env);
59 if not config_chunk then 50 if not config_chunk then
60 print("There was an error loading the config file, check the file exists"); 51 print("There was an error loading the config file, check the file exists");
61 print("and that the syntax is correct:"); 52 print("and that the syntax is correct:");
62 print("", err); 53 print("", err);
63 os.exit(1); 54 os.exit(1);