-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.lua
32 lines (27 loc) · 903 Bytes
/
run.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- very simple tool for running in the context of spook
-- run like "luajit run.lua some/file/here.moon"
local file = arg[1]
package.path = package.path .. ';spec/support/?.lua'
package.path = package.path .. ';spec/support/?/init.lua'
package.path = package.path .. ';lib/?.lua'
package.path = package.path .. ';lib/?/init.lua'
package.path = package.path .. ';vendor/?.lua'
package.path = package.path .. ';vendor/?/init.lua'
package.loaded.lfs = require('syscall.lfs')
local lpeg = require'lpeglj'
package.loaded.lpeg = lpeg
require'syscall'
require'moonscript'
local moonscript = require'moonscript.base'
package.moonpath = moonscript.create_moonpath(package.path)
newarg = {}
newarg[0] = file
newarg[-1] = "run.lua"
if #arg > 1 then
for i=2,#arg do
table.insert(newarg, arg[i])
end
end
_G.arg = newarg
chunk = assert(moonscript.loadfile(file), "Failed to load file: " .. file)
chunk()