summaryrefslogtreecommitdiff
path: root/src/luarocks/config.lua
blob: 019b3885054164d26dc42db08d522167af406c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local config = {}

local persist = require("luarocks.persist")

local cfg_skip = {
   errorcodes = true,
   flags = true,
   platforms = true,
   root_dir = true,
   upload_servers = true,
}

function config.should_skip(k, v)
   return type(v) == "function" or cfg_skip[k]
end

local function cleanup(tbl)
   local copy = {}
   for k, v in pairs(tbl) do
      if not config.should_skip(k, v) then
         copy[k] = v
      end
   end
   return copy
end

function config.get_config_for_display(cfg)
   return cleanup(cfg)
end

function config.to_string(cfg)
   local cleancfg = config.get_config_for_display(cfg)
   return persist.save_from_table_to_string(cleancfg)
end

return config