summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json2
-rw-r--r--server/src/async/scanfiles.lua13
-rw-r--r--server/src/utility.lua25
3 files changed, 31 insertions, 9 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 822d068a..6aad7fcd 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,3 @@
{
- "Lua.workspace.ignoreDir": ["publish", "bee.lua"]
+ "Lua.workspace.ignoreDir": ["publish", "server/bee.lua"]
}
diff --git a/server/src/async/scanfiles.lua b/server/src/async/scanfiles.lua
index 4829f8e1..f53564f8 100644
--- a/server/src/async/scanfiles.lua
+++ b/server/src/async/scanfiles.lua
@@ -2,16 +2,17 @@ local args = ...
require 'utility'
local fs = require 'bee.filesystem'
-local ignore = {
- ['.git'] = true,
- ['node_modules'] = true,
-}
+local ignore = { '.git', 'node_modules' }
+local root = fs.absolute(fs.path(args.root))
for name in pairs(args.ignore) do
- ignore[name] = true
+ ignore[#ignore+1] = name
+end
+for i, name in ipairs(ignore) do
+ ignore[i] = root / name
end
-for path in io.scan(fs.path(args.root), ignore) do
+for path in io.scan(root, ignore) do
if path:extension():string() == '.lua' then
local buf = io.load(path)
if buf then
diff --git a/server/src/utility.lua b/server/src/utility.lua
index 1fda5406..ee15bf38 100644
--- a/server/src/utility.lua
+++ b/server/src/utility.lua
@@ -146,6 +146,28 @@ end
function io.scan(path, ignore)
local result = {path}
local i = 0
+ local absolute
+ if ignore then
+ absolute = {}
+ for _, name in ipairs(ignore) do
+ local absoluteName = fs.path(name):string():lower()
+ absolute[#absolute+1] = absoluteName
+ end
+ end
+
+ local function isIgnored(path)
+ if not absolute then
+ return false
+ end
+ local target = path:string():lower()
+ for _, name in ipairs(absolute) do
+ if target == name then
+ return true
+ end
+ end
+ return false
+ end
+
return function ()
i = i + 1
local current = result[i]
@@ -153,8 +175,7 @@ function io.scan(path, ignore)
return nil
end
if fs.is_directory(current) then
- local dirName = current:filename():string():lower()
- if not ignore or not ignore[dirName] then
+ if not isIgnored(current) then
for path in current:list_directory() do
result[#result+1] = path
end