Skip to content

Commit 5d60eb5

Browse files
ChristophLHRColdIV
andcommitted
Small Fixes. Testsuit not working
Co-authored-by: Josh <dev@cldv.org>
1 parent d9f55ae commit 5d60eb5

File tree

4 files changed

+30
-1062
lines changed

4 files changed

+30
-1062
lines changed

libs/scm/config.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,35 @@ do
5858
function Config:saveConfig(config)
5959
config = config or self.config
6060

61-
local file = io.open(config["configDirectory"] .. config["configFile"], "w")
61+
local file = fs.open(config["configDirectory"] .. config["configFile"], "w")
6262
if not file then
6363
os.execute("mkdir " .. config["configDirectory"])
64-
file = io.open(config["configDirectory"] .. config["configFile"], "w")
64+
file = fs.open(config["configDirectory"] .. config["configFile"], "w")
6565
end
66-
file:write(textutils.serializeJSON(config))
67-
file:close()
66+
file.write(textutils.serializeJSON(config))
67+
file.close()
6868
end
6969

7070
--- loads the config from the config file
7171
---@param config SCMConfigData | nil
7272
function Config:loadConfig(config)
7373
config = config or self.config
74-
local file = io.open(config["configDirectory"] .. config["configFile"], "r")
74+
local file = fs.open(config["configDirectory"] .. config["configFile"], "r")
7575

7676
if not file then
7777
-- Create config file if it does not exist yet
7878
self:saveConfig(config)
7979
else
8080
-- Load config from file
81-
local temp = textutils.unserializeJSON(file:read("*all")) or {}
81+
local temp = textutils.unserializeJSON(file.readAll()) or {}
8282
-- Check if loaded config size is equal to the default size,
8383
-- otherwise the config is corrupted and will be overwritten
8484
if tablelength(temp) == tablelength(self.config) then
8585
self.config = temp
8686
else
8787
self:saveConfig(config)
8888
end
89-
file:close()
89+
file.close()
9090
end
9191
end
9292

libs/scm/net.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,32 @@ do
114114
local file = fs.open(targetDirectory .. sourceObject.name
115115
.. config()[sourceObject.type .. "Suffix"]
116116
.. "/" .. config()["infoFile"], "w")
117-
file:write(content)
118-
file:close()
117+
file.write(content)
118+
file.close()
119119

120120
local filePaths = {}
121121
if fs then
122122
file = fs.open(targetDirectory .. sourceObject.name
123123
.. config()[sourceObject.type .. "Suffix"]
124124
.. "/" .. config()["infoFile"], "r")
125125

126-
local line = file:read()
126+
local line = file.read()
127127
while line do
128128
filePaths[#filePaths + 1] = line
129-
line = file:read()
129+
line = file.read()
130130
end
131-
file:close()
131+
file.close()
132132
else
133133
file = fs.open(targetDirectory .. sourceObject.name
134134
.. config()[sourceObject.type .. "Suffix"]
135135
.. "/" .. config()["infoFile"], "r")
136-
-- print(file:read())
137-
local line = file:read()
136+
-- print(file.read())
137+
local line = file.read()
138138
while line do
139139
filePaths[#filePaths + 1] = line
140-
line = file:read()
140+
line = file.read()
141141
end
142-
file:close()
142+
file.close()
143143
end
144144
for i = 1, #filePaths, 1 do
145145
local success = true
@@ -157,8 +157,8 @@ do
157157
.. config()[sourceObject.type .. "Suffix"]
158158
.. "/" .. filePaths[i], "w")
159159
end
160-
tmpFile:write(tmpContent)
161-
tmpFile:close()
160+
tmpfile.write(tmpContent)
161+
tmpfile.close()
162162
else
163163
success = false
164164
end
@@ -232,8 +232,8 @@ do
232232
os.execute("mkdir " .. targetDirectory)
233233
file = fs.open(targetDirectory .. sourceObject.name, "w")
234234
end
235-
file:write(content)
236-
file:close()
235+
file.write(content)
236+
file.close()
237237
return sourceObject, true
238238
end
239239
end
@@ -291,13 +291,13 @@ do
291291
if not file then
292292
self:refreshRepoScripts()
293293
else
294-
local repoScripts = textutils.unserializeJSON(file:read("*all")) or nil
294+
local repoScripts = textutils.unserializeJSON(file.readAll()) or nil
295295
if repoScripts then
296296
SCM.Autocomplete:setProgramms(repoScripts["programs"])
297297
SCM.Autocomplete:setLibaries(repoScripts["libraries"])
298298
end
299299

300-
file:close()
300+
file.close()
301301
end
302302
end
303303

@@ -346,8 +346,8 @@ do
346346
file = fs.open(config()["configDirectory"] .. config()["repoScriptsFile"], "w")
347347
end
348348
if file then
349-
file:write(textutils.serializeJSON(repoScripts))
350-
file:close()
349+
file.write(""..textutils.serializeJSON(repoScripts))
350+
file.close()
351351
end
352352
end
353353

libs/scm/scriptManager.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ do
2121
if not file then
2222
self:saveScripts()
2323
else
24-
self.scripts = textutils.unserializeJSON(file:read("*all") or "")
25-
file:close()
24+
self.scripts = textutils.unserializeJSON(file.readAll() or "")
25+
file.close()
2626
if not self.scripts then
2727
self.scripts = {}
2828
end
@@ -36,8 +36,8 @@ do
3636
os.execute("mkdir " .. config["configDirectory"])
3737
file = fs.open(config["configDirectory"] .. config["scriptFile"], "w")
3838
end
39-
file:write(textutils.serializeJSON(self.scripts))
40-
file:close()
39+
file.write(""..textutils.serializeJSON(self.scripts))
40+
file.close()
4141
end
4242

4343
---adds a script to the script File
@@ -185,7 +185,7 @@ function ScriptManager:checkRequirements(name, localPath)
185185
-- Find requirements by searching for comment --@requires name
186186
local requires = {}
187187
while true do
188-
local line = file:read()
188+
local line = file.read()
189189
if not line then break end
190190

191191
local find = string.find(line, "--@requires")
@@ -203,7 +203,7 @@ function ScriptManager:checkRequirements(name, localPath)
203203
requires[#requires + 1] = scriptName
204204
end
205205
end
206-
file:close()
206+
file.close()
207207

208208
-- Install missing requirements
209209
for i = 1, #requires do

0 commit comments

Comments
 (0)