aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/cfg.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/cfg.lua')
-rw-r--r--src/luarocks/cfg.lua30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index e864c9fd..7aaacc76 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -146,16 +146,17 @@ cfg.variables = {}
146cfg.rocks_trees = {} 146cfg.rocks_trees = {}
147 147
148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" 148sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua"
149local err, errcode 149do
150sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 150 local err, errcode
151
152if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
153 sys_config_file = sys_config_dir.."/config.lua"
154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) 151 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
155end 152 if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file
156if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error 153 sys_config_file = sys_config_dir.."/config.lua"
157 io.stderr:write(err.."\n") 154 sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg)
158 os.exit(cfg.errorcodes.CONFIGFILE) 155 end
156 if (not sys_config_ok) and errcode ~= "open" then -- either "load" or "run"; bad config file, bail out with error
157 io.stderr:write(err.."\n")
158 os.exit(cfg.errorcodes.CONFIGFILE)
159 end
159end 160end
160 161
161local env_for_config_file = { 162local env_for_config_file = {
@@ -590,7 +591,16 @@ function cfg.init_package_paths()
590end 591end
591 592
592function cfg.which_config() 593function cfg.which_config()
593 return sys_config_file, sys_config_ok, home_config_file, home_config_ok 594 return {
595 system = {
596 file = sys_config_file,
597 ok = sys_config_ok,
598 },
599 user = {
600 file = home_config_file,
601 ok = home_config_ok,
602 }
603 }
594end 604end
595 605
596cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch 606cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch