Skip to content

Commit 7c9503e

Browse files
committed
add meta file for bee.filesystem
1 parent 01a09c6 commit 7c9503e

File tree

6 files changed

+46
-11
lines changed

6 files changed

+46
-11
lines changed

.luarc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"script/?.lua",
2525
"script/?/init.lua",
2626
"test/?.lua",
27-
"test/?/init.lua"
27+
"test/?/init.lua",
28+
"script/meta/?.lua"
2829
],
2930
"pathStrict": true
3031
},

debugger.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ end
55
local fs = require 'bee.filesystem'
66
local luaDebugs = {}
77

8+
local home = os.getenv 'USERPROFILE' or os.getenv 'HOME'
9+
if not home then
10+
log.error('Cannot find home directory')
11+
return
12+
end
813
for _, vscodePath in ipairs { '.vscode', '.vscode-insiders', '.vscode-server-insiders' } do
9-
local extensionPath = fs.path(os.getenv 'USERPROFILE' or os.getenv 'HOME') / vscodePath / 'extensions'
14+
local extensionPath = fs.path(home) / vscodePath / 'extensions'
1015
log.debug('Search extensions at:', extensionPath:string())
1116

1217
if fs.exists(extensionPath) then

script/fs-utility.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ local tableSort = table.sort
1313

1414
_ENV = nil
1515

16-
---@class fspath
17-
---@field string fun(self):string
18-
1916
---@class fs-utility
2017
local m = {}
2118
--- 读取文件
@@ -465,7 +462,7 @@ local function fileCopy(source, target, option)
465462
if isDir2 or fsCreateDirectories(target, option) then
466463
for filePath in fsPairs(source) do
467464
local name = filePath:filename():string()
468-
fileCopy(filePath, target / name--[[@as fspath]], option)
465+
fileCopy(filePath, target / name, option)
469466
end
470467
end
471468
else
@@ -487,6 +484,9 @@ local function fileCopy(source, target, option)
487484
end
488485
end
489486

487+
---@param source fspath?
488+
---@param target fspath?
489+
---@param option table
490490
local function fileSync(source, target, option)
491491
if not source or not target then
492492
return
@@ -516,7 +516,7 @@ local function fileSync(source, target, option)
516516
if fsCreateDirectories(target) then
517517
for filePath in fsPairs(source) do
518518
local name = filePath:filename():string()
519-
fileCopy(filePath, target / name--[[@as fspath]], option)
519+
fileCopy(filePath, target / name, option)
520520
end
521521
end
522522
end

script/library.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ local function initBuiltIn(uri)
214214
version = version,
215215
language = langID,
216216
encoding = encoding,
217-
})--[[@as fspath]]
217+
})
218218

219219
local metaLang = loadMetaLocale('en-US')
220220
if langID ~= 'en-US' then
@@ -245,7 +245,7 @@ local function initBuiltIn(uri)
245245
end
246246
libName = libName .. '.lua'
247247
---@type fspath
248-
local libPath = templateDir / libName--[[@as fspath]]
248+
local libPath = templateDir / libName
249249
local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
250250
if metaDoc then
251251
metaDoc = encoder.encode(encoding, metaDoc, 'auto')
@@ -262,8 +262,9 @@ local function initBuiltIn(uri)
262262
end
263263
end
264264

265+
---@param libraryDir fspath
265266
local function loadSingle3rdConfig(libraryDir)
266-
local configText = fsu.loadFile(libraryDir / 'config.lua'--[[@as fspath]])
267+
local configText = fsu.loadFile(libraryDir / 'config.lua')
267268
if not configText then
268269
return nil
269270
end

script/meta/bee/filesystem.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---@class fspath
2+
---@operator div: fspath
3+
local fsPath = {}
4+
5+
---@return string
6+
function fsPath:string()
7+
end
8+
9+
---@return fspath
10+
function fsPath:parent_path()
11+
end
12+
13+
---@return boolean
14+
function fsPath:is_relative()
15+
end
16+
17+
---@return fspath
18+
function fsPath:filename()
19+
end
20+
21+
local fs = {}
22+
23+
---@param path string
24+
---@return fspath
25+
function fs.path(path)
26+
end
27+
28+
return fs

script/version.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local fsu = require 'fs-utility'
22

33
local function loadVersion()
4-
local changelog = fsu.loadFile(ROOT / 'changelog.md'--[[@as fspath]])
4+
local changelog = fsu.loadFile(ROOT / 'changelog.md')
55
if not changelog then
66
return
77
end

0 commit comments

Comments
 (0)