Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix init buildin meta error #1465

Merged
merged 1 commit into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions script/fs-utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function dfs:saveFile(path, text)
return false, '无法打开:' .. path
end
dir[filename] = text
return true
end

---@param path string|fs.path
Expand Down
19 changes: 15 additions & 4 deletions script/library.lua
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,25 @@ local function initBuiltIn(uri)
if status == 'disable' then
goto CONTINUE
end
libName = libName .. '.lua'

---@type fs.path
local libPath = templateDir / libName
local libPath = templateDir / (libName .. '.lua')
local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
if metaDoc then
metaDoc = encoder.encode(encoding, metaDoc, 'auto')
out:saveFile(libName, metaDoc)
local outputPath = metaPath / libName

local outputLibName = libName:gsub('%.', '/') .. '.lua'
if outputLibName ~= libName then
out:createDirectories(fs.path(outputLibName):parent_path())
end

local ok, err = out:saveFile(outputLibName, metaDoc)
if not ok then
log.debug("Save Meta File:", err)
goto CONTINUE
end

local outputPath = metaPath / outputLibName
m.metaPaths[outputPath:string()] = true
log.debug('Meta path:', outputPath:string())
end
Expand Down