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

Cleanup artifacts after analyzing #266

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
43 changes: 25 additions & 18 deletions .lune/analyze.luau
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
local process = require("@lune/process")

local constants = require("./lib/constants")
local rmrf = require("./lib/rmrf")
local run = require("./lib/run")

local globalDefsPath = "globalTypes.d.luau"
local GLOBAL_DEFS_PATH = "globalTypes.d.luau"
local GLOBAL_DEFS_URL = "https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scripts/globalTypes.d.lua"

run("curl", {
"-s",
"-o",
globalDefsPath,
"-O",
"https://raw.githubusercontent.com/JohnnyMorganz/luau-lsp/master/scripts/globalTypes.d.lua",
})
run("curl", { "-s", "-o", GLOBAL_DEFS_PATH, "-O", GLOBAL_DEFS_URL })

run("rojo", {
"sourcemap",
Expand All @@ -18,13 +16,22 @@ run("rojo", {
constants.SOURCEMAP_PATH,
})

run("luau-lsp", {
"analyze",
`--sourcemap={constants.SOURCEMAP_PATH}`,
`--defs={globalDefsPath}`,
"--settings=./.vscode/settings.json",
"--ignore=**/_Index/**",
constants.SOURCE_PATH,
constants.LUNE_SCRIPTS_PATH,
constants.EXAMPLE_PATH,
})
local success = pcall(function()
return run("luau-lsp", {
"analyze",
`--sourcemap={constants.SOURCEMAP_PATH}`,
`--defs={GLOBAL_DEFS_PATH}`,
"--settings=./.vscode/settings.json",
"--ignore=**/_Index/**",
constants.SOURCE_PATH,
constants.LUNE_SCRIPTS_PATH,
constants.EXAMPLE_PATH,
})
end)

rmrf(GLOBAL_DEFS_PATH)
rmrf(constants.SOURCEMAP_PATH)

if not success then
process.exit(1)
end
8 changes: 4 additions & 4 deletions .lune/lib/run.luau
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ local function run(program: string, params: { string }, options: Options?)
env = if options then options.env else nil,
})

if result.code > 0 then
process.exit(result.code)
end

local output = if result.ok then result.stdout else result.stderr

output = output:gsub("\n$", "")

if not result.ok or result.code > 0 then
error(output)
end

return output
end

Expand Down
Loading