()
| 5 | var loadingData = true; |
| 6 | |
| 7 | async function InitData() { |
| 8 | if (!await DirExist(Config.SaveDirPath)) { |
| 9 | await CreateIfNotExist(Config.SaveDirPath + `/${global.resourceName}.json`, "{}"); |
| 10 | } |
| 11 | |
| 12 | ReadDir(Config.SaveDirPath).then(async function (files) { |
| 13 | let promises = []; |
| 14 | for (let i = 0; i < files.length; i++) { |
| 15 | if (!files[i].endsWith(".json")) continue; |
| 16 | let fileName = files[i].replace(".json", ""); |
| 17 | promises.push(ReadFile(Config.SaveDirPath + "/" + files[i]).then(function (data) { |
| 18 | loadedData[fileName] = JSON.parse(data); |
| 19 | })); |
| 20 | } |
| 21 | await Promise.all(promises); |
| 22 | loadingData = false; |
| 23 | Log(LogTypes.Debug, `Loaded data from: ${files.map(file => file.replace(".json", "")).join(", ")}`); |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | // module.exports = { InitData } |
nothing calls this directly
no test coverage detected