Open linonetwo opened 3 years ago
This is similar to https://github.com/desktop/dugite/issues/414
Same issue here
Not the same case, but i get SyntaxError: Unexpected end of JSON input
when the settings file is empty. It's not exactly an issue, cause json files shouldn't be empty, but i would suggest to the developer adding emptiness check just in case.
I also ran into this issue, after digging into it a bit, this is partially due to how the set()
/setSync()
are designed.
Both of these "write" functions loads existing settings from disk first and perform a partial update by path with the new data, because of this, when the settings data file on disk has invalid JSON format, the loading/parsing fails and thus fails the write function call.
I can think of two things to help solve this:
saveSettings()
/saveSettingsSync()
as a simpler pure/no-side-effect write counter part of set()
/setSync()
regardless of preexisting data and contrast their usage differences in doc.