Skip to content

Commit a79bc9b

Browse files
committed
ConfigHandler\write(): encode JSON before getting a handle on the config file
1 parent e965ec4 commit a79bc9b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

modules/DependencyControl/ConfigHandler.moon

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,18 @@ Reload your automation scripts to generate a new configuration file.]]
229229
@releaseLock!
230230
return false, err
231231

232+
-- create JSON
233+
success, res = pcall json.encode, config
234+
unless success
235+
@releaseLock!
236+
return false, res
237+
232238
-- write the whole config file in one go
233239
handle, err = io.open(@file, "w")
234240
unless handle
235241
@releaseLock!
236242
return false, err
237243

238-
success, res = pcall json.encode, config
239-
unless success
240-
@releaseLock!
241-
return false, res
242-
243244

244245
handle\setvbuf "full"
245246
handle\write res

0 commit comments

Comments
 (0)