Skip to content

Commit bb9b48b

Browse files
committed
don't swallow lua errors when in watch mode
1 parent 79c33bb commit bb9b48b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bin/moonc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ function get_sleep_func()
241241
end) then
242242
sleep = moonscript._sleep
243243
end
244+
if not sleep then
245+
error("Missing sleep function; install LuaSocket")
246+
end
244247
return sleep
245248
end
246249

@@ -254,12 +257,13 @@ end
254257

255258
-- returns an iterator that returns files that have been updated
256259
function create_watcher(files)
257-
local msg = "Starting watch loop, Ctrl-C to exit"
260+
local msg = "Starting watch loop (Ctrl-C to exit)"
258261

259262
local inotify
260263
pcall(function()
261264
inotify = require "inotify"
262265
end)
266+
inotify = nil
263267

264268
if inotify then
265269
local dirs = {}
@@ -324,7 +328,11 @@ if opts.w then
324328
-- catches interrupt error for ctl-c
325329
local protected = function()
326330
local status, file = pcall(watcher)
327-
if status then return file end
331+
if status then
332+
return file
333+
elseif file ~= "interrupted!" then
334+
error(file)
335+
end
328336
end
329337

330338
for fname in protected do

0 commit comments

Comments
 (0)