Skip to content

Commit 144b1bd

Browse files
committed
fix api
1 parent 39dc72a commit 144b1bd

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

resources/luajitCompact.lua

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ end
66

77
function defer(toBeClosed, callback)
88
local ctype = type(toBeClosed)
9-
if ctype == 'table' then
10-
local meta = getmetatable(toBeClosed)
11-
if meta and meta.__close then
12-
local ok, result = xpcall(callback, log.error)
13-
meta.__close(toBeClosed)
14-
if ok then
15-
return result
16-
end
17-
else
18-
local ok, result = xpcall(callback, log.error)
19-
if ok then
20-
return result
21-
end
9+
local meta = getmetatable(toBeClosed)
10+
if meta and meta.__close then
11+
local ok, result = xpcall(callback, log.error)
12+
meta.__close(toBeClosed)
13+
if ok then
14+
return result
2215
end
2316
elseif ctype == 'function' then
2417
local ok, result = xpcall(callback, log.error)
2518
toBeClosed()
2619
if ok then
27-
return result
20+
return result
21+
end
22+
else
23+
local ok, result = xpcall(callback, log.error)
24+
if ok then
25+
return result
2826
end
2927
end
3028
end
@@ -50,4 +48,4 @@ function math.type(x)
5048
else
5149
return nil
5250
end
53-
end
51+
end

resources/main.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ xpcall(dofile, log.debug, (ROOT / 'debugger.lua'):string())
7979

8080
require 'cli'
8181

82-
-- local _, service = xpcall(require, log.error, 'service')
83-
local service = require 'service'
82+
local _, service = xpcall(require, log.error, 'service')
8483

8584
service.start()

0 commit comments

Comments
 (0)