Discord
Login
Community
DARK THEME

system.project.writeFile( "assets/generated/jsonfile",...) does not update file but creates new

the writeFile function generates a new file when i try to rewrite a file like

system.project.writeFile( "assets/generated/jsonfile", obj, object ext = "json" end, function(result, error) print(result) end )
system.project.writeFile( "assets/generated/jsonfile", obj, object ext = "json" end, function(result, error) print(result) end )
system.project.writeFile( "assets/generated/jsonfile", obj, object ext = "json" end, function(result, error) print(result) end )

that will lead to 3 files called jsonfile, jsonfile2, jsonfile3

please add an updateFile function that will overwrite a file, or change the behavior of the writeFile function that it overwrites the file by given path and not generating some new ones

object replace = "true" end

system.project.writeFile( "assets/generated/jsonfile", obj, object ext = "json" replace = "true" end, function(result, error) print(result) end )

If you have this file open in an editor, you will only see the changes after opening another file and reopening the file you overwrote.

Thanks, who can add this to the docs? Missing it here: https://microstudio.dev/documentation/API-cheatsheet/

The documentation was probably written before this feature appeared.

I found that you can overwrite files by analyzing the MicroStuido code on github.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community