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.lua17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index 8a783237..9fce84f8 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -91,6 +91,7 @@ end
91-- Path configuration: 91-- Path configuration:
92 92
93local sys_config_file, home_config_file 93local sys_config_file, home_config_file
94local sys_config_ok, home_config_ok = false, false
94if detected.windows or detected.mingw32 then 95if detected.windows or detected.mingw32 then
95 home = os.getenv("APPDATA") or "c:" 96 home = os.getenv("APPDATA") or "c:"
96 sys_config_file = "c:/luarocks/config.lua" 97 sys_config_file = "c:/luarocks/config.lua"
@@ -106,12 +107,18 @@ end
106variables = {} 107variables = {}
107rocks_trees = {} 108rocks_trees = {}
108 109
109persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M) 110local ok, err = persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M)
111if ok then
112 sys_config_ok = true
113elseif err and ok == nil then
114 io.stderr:write(err.."\n")
115end
110 116
111if not site_config.LUAROCKS_FORCE_CONFIG then 117if not site_config.LUAROCKS_FORCE_CONFIG then
112 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file 118 home_config_file = os.getenv("LUAROCKS_CONFIG") or home_config_file
113 local home_overrides = persist.load_into_table(home_config_file, { home = home }) 119 local home_overrides, err = persist.load_into_table(home_config_file, { home = home })
114 if home_overrides then 120 if home_overrides then
121 home_config_ok = true
115 local util = require("luarocks.util") 122 local util = require("luarocks.util")
116 if home_overrides.rocks_trees then 123 if home_overrides.rocks_trees then
117 _M.rocks_trees = nil 124 _M.rocks_trees = nil
@@ -120,6 +127,8 @@ if not site_config.LUAROCKS_FORCE_CONFIG then
120 _M.rocks_servers = nil 127 _M.rocks_servers = nil
121 end 128 end
122 util.deep_merge(_M, home_overrides) 129 util.deep_merge(_M, home_overrides)
130 elseif err and home_overrides == nil then
131 io.stderr:write(err.."\n")
123 end 132 end
124end 133end
125 134
@@ -404,6 +413,10 @@ for _,tree in ipairs(rocks_trees) do
404 end 413 end
405end 414end
406 415
416function which_config()
417 return sys_config_file, sys_config_ok, home_config_file, home_config_ok
418end
419
407--- Check if platform was detected 420--- Check if platform was detected
408-- @param query string: The platform name to check. 421-- @param query string: The platform name to check.
409-- @return boolean: true if LuaRocks is currently running on queried platform. 422-- @return boolean: true if LuaRocks is currently running on queried platform.