Skip to content

Commit 0bc550b

Browse files
committed
allow using .lua file extension in the command line
* e.g., lunatik [run|stop] <script>.lua
1 parent 738c29f commit 0bc550b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/lunatik/runner.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ local env = lunatik._ENV
1111

1212
local runner = {}
1313

14+
local function trim(script) -- drop ".lua" file extension
15+
return script:gsub("(%w+).lua", "%1")
16+
end
17+
1418
function runner.run(script, ...)
19+
local script = trim(script)
1520
if env.runtimes[script] then
1621
error(string.format("%s is already running", script))
1722
end
@@ -36,6 +41,7 @@ local function stop(registry, script)
3641
end
3742

3843
function runner.stop(script)
44+
local script = trim(script)
3945
stop(env.threads, script)
4046
stop(env.runtimes, script)
4147
end

0 commit comments

Comments
 (0)