mirror of
https://github.com/leafo/moonscript.git
synced 2024-11-22 02:44:23 +00:00
Merge pull request #225 from ChickenNuggers/master
Add lint option to watcher
This commit is contained in:
commit
029fc46581
22
bin/moonc
22
bin/moonc
@ -264,6 +264,15 @@ local function create_watcher(files)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- build function to check for lint or compile in watch
|
||||||
|
local check_compile_or_lint
|
||||||
|
if opts.l then
|
||||||
|
local lint = require "moonscript.cmd.lint"
|
||||||
|
check_compile_or_lint = lint.lint_file
|
||||||
|
else
|
||||||
|
check_compile_or_lint = compile_and_write
|
||||||
|
end
|
||||||
|
|
||||||
if opts.w then
|
if opts.w then
|
||||||
local watcher = create_watcher(files)
|
local watcher = create_watcher(files)
|
||||||
-- catches interrupt error for ctl-c
|
-- catches interrupt error for ctl-c
|
||||||
@ -283,8 +292,14 @@ if opts.w then
|
|||||||
target = opts.o
|
target = opts.o
|
||||||
end
|
end
|
||||||
|
|
||||||
local success, err = compile_and_write(fname, target)
|
local success, err = check_compile_or_lint(fname, target)
|
||||||
if not success then
|
if opts.l then
|
||||||
|
if success then
|
||||||
|
io.stderr:write(success .. "\n\n")
|
||||||
|
elseif err then
|
||||||
|
io.stderr:write(fname .. "\n" .. err .. "\n\n")
|
||||||
|
end
|
||||||
|
elseif not success then
|
||||||
io.stderr:write(table.concat({
|
io.stderr:write(table.concat({
|
||||||
"",
|
"",
|
||||||
"Error: " .. fname,
|
"Error: " .. fname,
|
||||||
@ -300,8 +315,7 @@ if opts.w then
|
|||||||
elseif opts.l then
|
elseif opts.l then
|
||||||
for _, tuple in pairs(files) do
|
for _, tuple in pairs(files) do
|
||||||
local fname = tuple[1]
|
local fname = tuple[1]
|
||||||
local lint = require "moonscript.cmd.lint"
|
local res, err = check_compile_or_lint(fname)
|
||||||
local res, err = lint.lint_file(fname)
|
|
||||||
if res then
|
if res then
|
||||||
io.stderr:write(res .. "\n\n")
|
io.stderr:write(res .. "\n\n")
|
||||||
elseif err then
|
elseif err then
|
||||||
|
Loading…
Reference in New Issue
Block a user