Skip to content

Commit

Permalink
Merge pull request #1465 from fesily/fix-initBuildIn
Browse files Browse the repository at this point in the history
fix init buildin meta error
  • Loading branch information
sumneko authored Aug 13, 2022
2 parents dacf711 + 5e099fc commit d104b72
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
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

0 comments on commit d104b72

Please sign in to comment.