summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-09 00:49:50 +0800
committerruki <[email protected]>2023-03-09 00:49:50 +0800
commita998fe06c24a2e041e6cf44a26437072e9b0c132 (patch)
treece7d21e8d54e674359d2e3326b04144aa84d7827
parent36bdca38baa44cba883108516e8d48866c7a54bb (diff)
improve find_file
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_file.lua24
1 files changed, 13 insertions, 11 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
index 60667c6f3..0c878e87d 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
@@ -90,21 +90,23 @@ function sandbox_lib_detect_find_file.main(name, paths, opt)
end
for _, _s_path in ipairs(table.wrap(_path)) do
- -- find file with suffixes
- if #suffixes > 0 then
- for _, suffix in ipairs(suffixes) do
- local filedir = path.join(_s_path, suffix)
- local results = sandbox_lib_detect_find_file._find(filedir, name)
+ if #_s_path > 0 then
+ -- find file with suffixes
+ if #suffixes > 0 then
+ for _, suffix in ipairs(suffixes) do
+ local filedir = path.join(_s_path, suffix)
+ local results = sandbox_lib_detect_find_file._find(filedir, name)
+ if results then
+ return results
+ end
+ end
+ else
+ -- find file in the given path
+ local results = sandbox_lib_detect_find_file._find(_s_path, name)
if results then
return results
end
end
- else
- -- find file in the given path
- local results = sandbox_lib_detect_find_file._find(_s_path, name)
- if results then
- return results
- end
end
end
end