summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-10 00:21:33 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-10 00:21:33 +0800
commit834d3eaba11352ba62e380262e8f7cdf5a8e048d (patch)
tree7f8f2d9cf57d2ab0f97b4af023605ee51dfea9b3 /script
parent2a9570cac436f4015453cef839600e5cf5f3f372 (diff)
downloadlua-language-server-834d3eaba11352ba62e380262e8f7cdf5a8e048d.zip
fix types
Diffstat (limited to 'script')
-rw-r--r--script/fs-utility.lua19
1 files changed, 14 insertions, 5 deletions
diff --git a/script/fs-utility.lua b/script/fs-utility.lua
index 792df1a8..9a45b1cc 100644
--- a/script/fs-utility.lua
+++ b/script/fs-utility.lua
@@ -171,6 +171,7 @@ function dfs:string()
return self.path
end
+---@return fun(): dummyfs?
function dfs:listDirectory()
local dir = self:_open()
if type(dir) ~= 'table' then
@@ -263,7 +264,7 @@ end
---@param path string|fs.path|dummyfs
---@param option table
----@return fs.path?
+---@return fs.path|dummyfs?
local function fsAbsolute(path, option)
if type(path) == 'string' then
local suc, res = pcall(fs.path, path)
@@ -459,7 +460,7 @@ local function fileRemove(path, option)
end
---@param source fs.path|dummyfs?
----@param target fs.path?
+---@param target fs.path|dummyfs?
---@param option table
local function fileCopy(source, target, option)
if not source or not target then
@@ -495,7 +496,7 @@ local function fileCopy(source, target, option)
end
---@param source fs.path|dummyfs?
----@param target fs.path?
+---@param target fs.path|dummyfs?
---@param option table
local function fileSync(source, target, option)
if not source or not target then
@@ -507,8 +508,16 @@ local function fileSync(source, target, option)
if isDir1 then
if isDir2 then
local fileList = m.fileList()
- for filePath in fs.pairs(target) do
- fileList[filePath] = true
+ if type(target) == 'table' then
+ ---@cast target dummyfs
+ for filePath in target:listDirectory() do
+ fileList[filePath] = true
+ end
+ else
+ ---@cast target fs.path
+ for filePath in fs.pairs(target) do
+ fileList[filePath] = true
+ end
end
for filePath in fsPairs(source, option) do
local name = filePath:filename():string()