Skip to content

Commit 7ce9002

Browse files
committed
feat(template): start work on template runner
1 parent 59971e3 commit 7ce9002

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/template/runner.cr

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module Lua
2+
class Runner
3+
@script : String
4+
@output : IO
5+
@state : Lua::State
6+
7+
def initialize(@script, @output)
8+
@state = Lua::State.new
9+
@state.open :all
10+
end
11+
12+
def load_normal_env : Nil
13+
Lua.create_function @state, "current_dir" do |_|
14+
Dir.current
15+
end
16+
17+
Lua.create_function @state, "run_command" do |args|
18+
command, *rest = args.map(&.as_s) rescue raise "expected all string arguments to 'run_command'"
19+
Process.run(command, rest).exit_code
20+
end
21+
end
22+
23+
def load_test_env : Nil
24+
Lua.create_function @state, "current_dir" do |_|
25+
Dir.current
26+
end
27+
28+
Lua.create_function @state, "run_command" do |_|
29+
0
30+
end
31+
end
32+
33+
def load_checks_env : Nil
34+
# TODO
35+
end
36+
37+
def run : Nil
38+
end
39+
end
40+
end

0 commit comments

Comments
 (0)