mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2025-07-31 13:10:33 +02:00
enable downlevelIteration build option in typescript
This commit is contained in:
31
libantosdk/build/debug/core/lua/api.lua
Normal file
31
libantosdk/build/debug/core/lua/api.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local args=...
|
||||
|
||||
local result = function(data)
|
||||
return { error = false, result = data }
|
||||
end
|
||||
|
||||
local error = function(msg)
|
||||
return {error = msg, result = false}
|
||||
end
|
||||
|
||||
local handle = {}
|
||||
|
||||
handle.exec = function(data)
|
||||
local cmd = data.cmd
|
||||
if data.pwd then
|
||||
cmd = "cd "..require("vfs").ospath(data.pwd).. " && "..cmd
|
||||
end
|
||||
cmd = cmd.." 2>&1"
|
||||
local pipe = io.popen(cmd)
|
||||
for line in pipe:lines() do
|
||||
echo(JSON.encode(result(line)))
|
||||
end
|
||||
pipe:close()
|
||||
return result("Done: ["..cmd.."]")
|
||||
end
|
||||
|
||||
if args.action and handle[args.action] then
|
||||
return handle[args.action](args.args)
|
||||
else
|
||||
return error("Invalid action parameter")
|
||||
end
|
Reference in New Issue
Block a user