mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
don't swallow lua errors when in watch mode
This commit is contained in:
parent
79c33bb007
commit
bb9b48b3ea
12
bin/moonc
12
bin/moonc
@ -241,6 +241,9 @@ function get_sleep_func()
|
|||||||
end) then
|
end) then
|
||||||
sleep = moonscript._sleep
|
sleep = moonscript._sleep
|
||||||
end
|
end
|
||||||
|
if not sleep then
|
||||||
|
error("Missing sleep function; install LuaSocket")
|
||||||
|
end
|
||||||
return sleep
|
return sleep
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -254,12 +257,13 @@ end
|
|||||||
|
|
||||||
-- returns an iterator that returns files that have been updated
|
-- returns an iterator that returns files that have been updated
|
||||||
function create_watcher(files)
|
function create_watcher(files)
|
||||||
local msg = "Starting watch loop, Ctrl-C to exit"
|
local msg = "Starting watch loop (Ctrl-C to exit)"
|
||||||
|
|
||||||
local inotify
|
local inotify
|
||||||
pcall(function()
|
pcall(function()
|
||||||
inotify = require "inotify"
|
inotify = require "inotify"
|
||||||
end)
|
end)
|
||||||
|
inotify = nil
|
||||||
|
|
||||||
if inotify then
|
if inotify then
|
||||||
local dirs = {}
|
local dirs = {}
|
||||||
@ -324,7 +328,11 @@ if opts.w then
|
|||||||
-- catches interrupt error for ctl-c
|
-- catches interrupt error for ctl-c
|
||||||
local protected = function()
|
local protected = function()
|
||||||
local status, file = pcall(watcher)
|
local status, file = pcall(watcher)
|
||||||
if status then return file end
|
if status then
|
||||||
|
return file
|
||||||
|
elseif file ~= "interrupted!" then
|
||||||
|
error(file)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for fname in protected do
|
for fname in protected do
|
||||||
|
Loading…
Reference in New Issue
Block a user