diff options
| author | ruki <[email protected]> | 2020-10-22 22:39:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-10-22 22:39:39 +0800 |
| commit | c420bcf06c11e7ac62c0e5a0873791572d6e3a59 (patch) | |
| tree | 12270d4e1bff917d184425da19807341575800b2 /xmake/plugins/lua/main.lua | |
| parent | 020c9da2c47ae5550a321147d189e8ddde5416c2 (diff) | |
add xrepo stub
Diffstat (limited to 'xmake/plugins/lua/main.lua')
| -rw-r--r-- | xmake/plugins/lua/main.lua | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/plugins/lua/main.lua b/xmake/plugins/lua/main.lua index a4ba1c93f..54b35cf0a 100644 --- a/xmake/plugins/lua/main.lua +++ b/xmake/plugins/lua/main.lua @@ -65,6 +65,17 @@ function _run_commanad(command, args) return _run_script(tmpfile, args) end +function _is_callable(func) + if type(func) == "function" then + return true + elseif type(func) == "table" then + local meta = debug.getmetatable(func) + if meta and meta.__call then + return true + end + end +end + function _run_script(script, args) local func @@ -108,7 +119,7 @@ function _run_script(script, args) _print_vlog(script_type or "script", script_name or "", args) -- dump func() result - if type(func) == "function" or (type(func) == "table" and func.main and type(func.main) == "function") then + if _is_callable(func) then local result = table.pack(func(table.unpack(args, 1, args.n))) if printresult and result and result.n ~= 0 then utils.dump(unpack(result, 1, result.n)) |
