move script_environment changes to test.lua

develop
myk002 2021-03-29 12:23:53 -07:00
parent e4cab1b1c6
commit 54a1e8d98a
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 14 additions and 6 deletions

@ -88,7 +88,17 @@ end
local test_scripts = {is_test_scripts=true}
local test_envvars = {}
local function clean_reqscript(name)
return dfhack.script_environment(name, true, test_envvars, test_scripts)
local path = dfhack.findScript(name)
if test_scripts[path] then return test_scripts[path].env end
local _, env = dfhack.run_script_with_env(
test_envvars,
name,
{
scripts=test_scripts,
module=true,
module_strict=true
})
return env
end
test_envvars.require = clean_require
test_envvars.reqscript = clean_reqscript

@ -602,15 +602,13 @@ function dfhack.reqscript(name)
end
reqscript = dfhack.reqscript
function dfhack.script_environment(name, strict, envVars, scripts)
scripts = scripts or internal.scripts
function dfhack.script_environment(name, strict)
local scripts = internal.scripts
local path = dfhack.findScript(name)
if not scripts[path] or scripts[path]:needs_update() then
local _, env = dfhack.run_script_with_env(
envVars,
local _, env = dfhack.run_script_with_env(nil,
name,
{
scripts=scripts,
module=true,
module_strict=(strict and true or false) -- ensure that this key is present if 'strict' is nil
})