don't swallow lua errors when in watch mode

This commit is contained in:
leaf corcoran 2011-11-30 19:25:41 -08:00
parent 79c33bb007
commit bb9b48b3ea

View File

@ -241,6 +241,9 @@ function get_sleep_func()
end) then
sleep = moonscript._sleep
end
if not sleep then
error("Missing sleep function; install LuaSocket")
end
return sleep
end
@ -254,12 +257,13 @@ end
-- returns an iterator that returns files that have been updated
function create_watcher(files)
local msg = "Starting watch loop, Ctrl-C to exit"
local msg = "Starting watch loop (Ctrl-C to exit)"
local inotify
pcall(function()
inotify = require "inotify"
end)
inotify = nil
if inotify then
local dirs = {}
@ -324,7 +328,11 @@ if opts.w then
-- catches interrupt error for ctl-c
local protected = function()
local status, file = pcall(watcher)
if status then return file end
if status then
return file
elseif file ~= "interrupted!" then
error(file)
end
end
for fname in protected do