Fix for files getting run twice by (use "")

This commit is contained in:
Bruce Hill 2018-12-15 15:14:26 -08:00
parent 3036d425a5
commit 17fc0a0e38
2 changed files with 27 additions and 11 deletions

View File

@ -322,18 +322,30 @@ local nomsu_environment = Importer({
break break
end end
for _index_0 = 1, #files do for _index_0 = 1, #files do
local filename = files[_index_0] local _continue_1 = false
local lua_filename = filename:gsub("%.nom$", ".lua") repeat
local code local filename = files[_index_0]
if optimization ~= 0 and Files.read(lua_filename) then local lua_filename = filename:gsub("%.nom$", ".lua")
local file = Files.read(lua_filename) if environment.FILE_CACHE[filename] then
code = LuaCode:from(Source(filename, 1, #file), file) import_to_1_from(environment, environment.FILE_CACHE[filename], prefix)
else _continue_1 = true
local file = Files.read(filename) break
code = NomsuCode:from(Source(filename, 1, #file), file) end
local code
if optimization ~= 0 and Files.read(lua_filename) then
local file = Files.read(lua_filename)
code = LuaCode:from(Source(filename, 1, #file), file)
else
local file = Files.read(filename)
code = NomsuCode:from(Source(filename, 1, #file), file)
end
environment.run_1_in(code, mod)
did_anything = true
_continue_1 = true
until true
if not _continue_1 then
break
end end
environment.run_1_in(code, mod)
did_anything = true
end end
break break
end end

View File

@ -179,6 +179,10 @@ nomsu_environment = Importer{
continue unless files continue unless files
for filename in *files for filename in *files
lua_filename = filename\gsub("%.nom$", ".lua") lua_filename = filename\gsub("%.nom$", ".lua")
-- Need to check here to prevent re-running files
if environment.FILE_CACHE[filename]
import_to_1_from(environment, environment.FILE_CACHE[filename], prefix)
continue
-- TODO: don't automatically use precompiled version? -- TODO: don't automatically use precompiled version?
code = if optimization != 0 and Files.read(lua_filename) code = if optimization != 0 and Files.read(lua_filename)
-- TODO: use a checksum? -- TODO: use a checksum?