diff options
| author | Saikari <[email protected]> | 2026-02-01 08:57:49 +0300 |
|---|---|---|
| committer | Saikari <[email protected]> | 2026-02-01 08:57:49 +0300 |
| commit | 09a702d482edc5fb7218900460442822e1303810 (patch) | |
| tree | 932237381f013c2f54c7826e5099c606e0287fdd /xmake/plugins/lua/main.lua | |
| parent | a6c7c34b0a3cba1f95a3411232bc566c62a661d0 (diff) | |
refactor: enhance script handling to support inline Lua content execution
Diffstat (limited to 'xmake/plugins/lua/main.lua')
| -rw-r--r-- | xmake/plugins/lua/main.lua | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/xmake/plugins/lua/main.lua b/xmake/plugins/lua/main.lua index b6951c276..0a608b10a 100644 --- a/xmake/plugins/lua/main.lua +++ b/xmake/plugins/lua/main.lua @@ -59,45 +59,24 @@ function main() if script or from_stdin then -- run script from stdin? - local scriptfile_stdin + local script_content if script == "-" or from_stdin then - local script_content = io.read("*a") - if script_content then - scriptfile_stdin = os.tmpfile("xmake_lua_stdin_" .. hash.uuid4()) .. ".lua" - io.writefile(scriptfile_stdin, script_content) - if from_stdin and script and script ~= "-" then - arguments = arguments or {} - table.insert(arguments, 1, script) - end - script = scriptfile_stdin + script_content = io.read("*a") + if not script or script == "-" then + script = "xmake_lua_stdin" end end - try { - function () - if script then - run_script(script, { - curdir = os.workingdir(), - verbose = option.get("verbose"), - diagnosis = option.get("diagnosis"), - command = option.get("command"), - arguments = arguments, - deserialize = option.get("deserialize")}) - end - end, - catch { - function (errors) - raise(errors) - end - }, - finally { - function () - if scriptfile_stdin then - os.rm(scriptfile_stdin) - end - end - } - } + if script then + run_script(script, { + curdir = os.workingdir(), + verbose = option.get("verbose"), + diagnosis = option.get("diagnosis"), + command = option.get("command"), + arguments = arguments, + content = script_content, + deserialize = option.get("deserialize")}) + end else -- enter interactive mode sandbox.interactive() |
