diff options
Diffstat (limited to 'src/luarocks/cfg.lua')
-rw-r--r-- | src/luarocks/cfg.lua | 30 |
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 = {} | |||
146 | cfg.rocks_trees = {} | 146 | cfg.rocks_trees = {} |
147 | 147 | ||
148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" | 148 | sys_config_file = site_config.LUAROCKS_SYSCONFIG or sys_config_dir.."/config-"..cfg.lua_version..".lua" |
149 | local err, errcode | 149 | do |
150 | sys_config_ok, err, errcode = persist.load_into_table(sys_config_file, cfg) | 150 | local err, errcode |
151 | |||
152 | if (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) |
155 | end | 152 | if (not sys_config_ok) and errcode == "open" then -- file not found, so try alternate file |
156 | if (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 | ||
159 | end | 160 | end |
160 | 161 | ||
161 | local env_for_config_file = { | 162 | local env_for_config_file = { |
@@ -590,7 +591,16 @@ function cfg.init_package_paths() | |||
590 | end | 591 | end |
591 | 592 | ||
592 | function cfg.which_config() | 593 | function 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 | } | ||
594 | end | 604 | end |
595 | 605 | ||
596 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch | 606 | cfg.user_agent = "LuaRocks/"..cfg.program_version.." "..cfg.arch |