-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.lua
40 lines (34 loc) · 890 Bytes
/
utils.lua
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
37
38
39
40
-------------------------------------------------------------
-- Carrot utilities
-------------------------------------------------------------
-- Licensed under the GNU General Public License v3:
-- https://opensource.org/licenses/GPL-3.0
-------------------------------------------------------------
-- Copyright (c) 2018 Pouyan Heyratpour <[email protected]>
-------------------------------------------------------------
local function merge(t, tp)
for k, v in pairs(tp) do
if "table" == type(v) then
if "table" == type(t[k] or false) then
t[k] = merge(t[k] or {}, tp[k] or {})
else
t[k] = v
end
else
t[k] = v
end
end
return t
end
local function fileExists(path)
fp = io.open(path, "r")
if nil == fp then
return false
end
fp:close()
return true
end
return {
Merge = merge;
FileExists = fileExists;
}