Skip to content

Commit e78e718

Browse files
committed
tools/script_manager - allow for inclusion of directory/package specific
libraries by adding "local" libraries to the search path to ensure they are found when needed.
1 parent 40949b3 commit e78e718

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎tools/script_manager.lua‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,25 @@ local function process_script_data(script_file)
509509
restore_log_level(old_log_level)
510510
end
511511

512+
local function ensure_lib_in_search_path(line)
513+
local old_log_level = set_log_level(sm.log_level)
514+
set_log_level(log.debug)
515+
log.msg(log.debug, "line is " .. line)
516+
if string.match(line, ds.sanitize_lua(dt.configuration.config_dir .. PS .. "lua/lib")) then
517+
log.msg(log.debug, line .. " is already in search path, returning...")
518+
return
519+
end
520+
local path = string.match(line, "(.+)/lib/.+lua")
521+
log.msg(log.debug, "extracted path is " .. path)
522+
log.msg(log.debug, "package.path is " .. package.path)
523+
if not string.match(package.path, ds.sanitize_lua(path)) then
524+
log.msg(log.debug, "path isn't in package.path, adding...")
525+
package.path = package.path .. ";" .. path .. "/?.lua"
526+
log.msg(log.debug, "new package.path is " .. package.path)
527+
end
528+
restore_log_level(old_log_level)
529+
end
530+
512531
local function scan_scripts(script_dir)
513532
local old_log_level = set_log_level(sm.log_level)
514533
local script_count = 0
@@ -529,6 +548,8 @@ local function scan_scripts(script_dir)
529548
process_script_data(script_file)
530549
script_count = script_count + 1
531550
end
551+
else
552+
ensure_lib_in_search_path(line) -- but let's make sure libraries can be found
532553
end
533554
end
534555
end

0 commit comments

Comments
 (0)