Implemented lazy load of platform specific functionallity, and a different test for that functionallity.
This commit is contained in:
parent
81626f6b1e
commit
9b284ee2ce
|
@ -56,24 +56,32 @@ local function package_config ()
|
|||
}
|
||||
end
|
||||
|
||||
local iterate_files_in_subfiles
|
||||
local iterate_files_in_subfiles = function (...)
|
||||
-- This outer function is a wrapper, that lazily loads the correct
|
||||
-- version of the iterate function, based on the availability of
|
||||
-- the commands.
|
||||
|
||||
if package_config().dir_sep == '/' then
|
||||
function iterate_files_in_subfiles (root_path)
|
||||
-- On unix
|
||||
-- Use `find` to find files in folders below the given matching.
|
||||
if os.execute 'find -false' == 0 then
|
||||
iterate_files_in_subfiles = function (root_path)
|
||||
-- On unix
|
||||
-- Use `find` to find files in folders below the given matching.
|
||||
|
||||
assert(type(root_path) == 'string')
|
||||
local start_directory = root_path:match '^(.-)?' or root_path
|
||||
local pfile = io.popen ('find -L "'..start_directory..'" -type f ! -path \'*/\\.*\' -print0 2> /dev/null')
|
||||
local list_str = pfile:read '*all'
|
||||
pfile:close()
|
||||
assert(type(root_path) == 'string')
|
||||
local start_directory = root_path:match '^(.-)?' or root_path
|
||||
local pfile = io.popen ('find -L "'..start_directory..'" -type f ! -path \'*/\\.*\' -print0 2> /dev/null')
|
||||
local list_str = pfile:read '*all'
|
||||
pfile:close()
|
||||
|
||||
return list_str:gmatch '[^%z]+'
|
||||
return list_str:gmatch '[^%z]+'
|
||||
end
|
||||
else
|
||||
-- Other platforms
|
||||
error '[suggest-require]: Your platform does not possess the "find" utility, and is thus not currently supported.'
|
||||
end
|
||||
else
|
||||
-- On windows
|
||||
error '[suggest-require]: Windows is not currently supported.'
|
||||
|
||||
-----
|
||||
|
||||
return iterate_files_in_subfiles(...)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -199,7 +207,7 @@ local function get_available_module_names ()
|
|||
for name in pairs(dedub) do module_names[#module_names+1] = name end
|
||||
table.sort(module_names)
|
||||
|
||||
-- Output assertions
|
||||
-- Assert that output is correctly formatted
|
||||
assert(type(module_names) == 'table')
|
||||
for i = 1, #module_names do
|
||||
assert(type(module_names[i]) == 'string')
|
||||
|
|
Loading…
Reference in New Issue
Block a user