mirror of
https://github.com/kepler155c/opus
synced 2025-10-31 23:53:01 +00:00
pure lua compatiblity fixes for moonlight, busted, etc
This commit is contained in:
25
sys/apps/compat.lua
Normal file
25
sys/apps/compat.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local Util = require('opus.util')
|
||||
|
||||
-- some programs expect to be run in the global scope
|
||||
-- ie. busted, moonscript
|
||||
|
||||
-- create a new sandbox mimicing pure lua
|
||||
|
||||
local fs = _G.fs
|
||||
local shell = _ENV.shell
|
||||
|
||||
local env = Util.shallowCopy(_G)
|
||||
Util.merge(env, _ENV)
|
||||
env._G = env
|
||||
|
||||
env.arg = { ... }
|
||||
env.arg[0] = shell.resolveProgram(table.remove(env.arg, 1))
|
||||
|
||||
_G.requireInjector(env, fs.getDir(env.arg[0]))
|
||||
|
||||
local s, m = Util.run(env, env.arg[0], table.unpack(env.arg))
|
||||
|
||||
if not s then
|
||||
error(m)
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ local fs = _G.fs
|
||||
local settings = _G.settings
|
||||
local shell = _ENV.shell
|
||||
|
||||
_G.requireInjector(_ENV)
|
||||
--_G.requireInjector(_ENV)
|
||||
|
||||
local trace = require('opus.trace')
|
||||
local Util = require('opus.util')
|
||||
@@ -43,6 +43,11 @@ local function run(...)
|
||||
local isUrl = not not command:match("^(https?:)")
|
||||
local env = shell.makeEnv(_ENV)
|
||||
|
||||
if command:match('(.+)%.moon$') then
|
||||
table.insert(args, 1, command)
|
||||
command = 'moon'
|
||||
end
|
||||
|
||||
local path, loadFn
|
||||
if isUrl then
|
||||
path = command
|
||||
|
||||
Reference in New Issue
Block a user