Repository navigation
Expand file tree
/
Copy pathLuaCompiler.lua
More file actions
77 lines (64 loc) · 2.41 KB
/
Copy pathLuaCompiler.lua
File metadata and controls
77 lines (64 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-- VARIABLES
local AppData = assert(os.getenv("LOCALAPPDATA"))
local CompilerPath = AppData .. "\\LuaCompiler"
local URL = "https://raw.githubusercontent.com/WhoBuscusYT/LuaCompiler/main/"
-- FUNCTIONS
local function InstallDirectory()
local success = os.execute(
'if not exist "' .. CompilerPath .. '" mkdir "' .. CompilerPath .. '" 2>nul'
)
if not success then
error("[LuaCompiler] Failed to create compiler directory!")
end
end
function DownloadFile(url, filename)
local destination = CompilerPath .. "\\" .. filename
local fullurl = url .. filename
local command = string.format(
'curl.exe -L -f -sS -o "%s" "%s"',
destination,
fullurl
)
local success = os.execute(command)
if not success then
error("[LuaCompiler] Failed to download: " .. filename)
end
print("[LuaCopmiler] Downloaded: " .. filename)
end
function UpdateFile(url, filename)
local destination = CompilerPath .. "\\" .. filename
local success, errorMessage = os.remove(destination)
if success then
print("[LuaCompiler] Successfully Deleted " .. filename .. ". Installing new version now.")
DownloadFile(url, filename)
else
error("[LuaCompiler] Failed to delete " .. filename .. ".")
end
end
local function AddToPath()
local command = [[powershell.exe -NoProfile -Command "$p = Join-Path $env:LOCALAPPDATA 'LuaCompiler'; $paths = [Environment]::GetEnvironmentVariable('Path', 'User') -split ';'; if ($p -notin $paths) { [Environment]::SetEnvironmentVariable('Path', (($paths + $p) -join ';').Trim(';'), 'User') }"]]
local success = os.execute(command)
if success then
print("[LuaCompiler] Added compiler to user PATH!")
print("[LuaCompiler] Restart your terminal to use 'luacompiler'.")
else
print("[LuaCompiler] Failed to update PATH.")
end
end
-- FUNCTION CALLING
InstallDirectory()
DownloadFile(URL, "GameCompile.lua")
DownloadFile(URL, "luacompiler.cmd")
DownloadFile(URL, "Updater.lua")
DownloadFile(URL, "Compiler.lua")
DownloadFile(URL, "Bundler.lua")
DownloadFile(URL, "Windows.lua")
DownloadFile(URL, "Builder.lua")
DownloadFile(URL, "Launcher.exe")
DownloadFile(URL, "Launcher.exe.sha256")
DownloadFile(URL, "Runtime.lcb")
DownloadFile(URL, "Runtime.lcb.sha256")
DownloadFile(URL, "THIRD-PARTY-LICENSES.txt")
DownloadFile(URL, "LUA-LICENSE.txt")
DownloadFile(URL, "SHA256SUMS")
AddToPath()