From d0b19d0a978b78d3fb4e6e5842af13736f58b316 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 13 Apr 2017 12:59:16 +1000 Subject: lua-cli: Run LUA_INIT if set --- tests/manual-tests/lua-cli.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/manual-tests/lua-cli.js b/tests/manual-tests/lua-cli.js index 0b5519b..e32067e 100755 --- a/tests/manual-tests/lua-cli.js +++ b/tests/manual-tests/lua-cli.js @@ -16,6 +16,24 @@ const L = lauxlib.luaL_newstate(); linit.luaL_openlibs(L); +let init = process.env["LUA_INIT"+lua.LUA_VERSUFFIX] || process.env["LUA_INIT"]; +if (init) { + let status; + if (init[0] === "@") { + status = lauxlib.luaL_loadfile(L, lua.to_luastring(init.substring(1))); + } else { + status = lauxlib.luaL_loadstring(L, lua.to_luastring(init)); + } + if (status === lua.thread_status.LUA_OK) { + status = lapi.lua_pcall(L, 0, 0, 0); + } + if (status !== lua.thread_status.LUA_OK) { + lauxlib.lua_writestringerror(`${lapi.lua_tojsstring(L, -1)}\n`); + lapi.lua_pop(L, 1); + return process.exit(1); + } +} + console.log(lua.FENGARI_COPYRIGHT); for (;;) { -- cgit v1.2.3-70-g09d2