Skip to content

Commit d104b72

Browse files
authored
Merge pull request #1465 from fesily/fix-initBuildIn
fix init buildin meta error
2 parents dacf711 + 5e099fc commit d104b72

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

script/fs-utility.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ function dfs:saveFile(path, text)
254254
return false, '无法打开:' .. path
255255
end
256256
dir[filename] = text
257+
return true
257258
end
258259

259260
---@param path string|fs.path

script/library.lua

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,25 @@ local function initBuiltIn(uri)
243243
if status == 'disable' then
244244
goto CONTINUE
245245
end
246-
libName = libName .. '.lua'
246+
247247
---@type fs.path
248-
local libPath = templateDir / libName
248+
local libPath = templateDir / (libName .. '.lua')
249249
local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
250250
if metaDoc then
251251
metaDoc = encoder.encode(encoding, metaDoc, 'auto')
252-
out:saveFile(libName, metaDoc)
253-
local outputPath = metaPath / libName
252+
253+
local outputLibName = libName:gsub('%.', '/') .. '.lua'
254+
if outputLibName ~= libName then
255+
out:createDirectories(fs.path(outputLibName):parent_path())
256+
end
257+
258+
local ok, err = out:saveFile(outputLibName, metaDoc)
259+
if not ok then
260+
log.debug("Save Meta File:", err)
261+
goto CONTINUE
262+
end
263+
264+
local outputPath = metaPath / outputLibName
254265
m.metaPaths[outputPath:string()] = true
255266
log.debug('Meta path:', outputPath:string())
256267
end

0 commit comments

Comments
 (0)