fix(tools): fs-path for parseData

This commit is contained in:
Walid 2023-04-23 23:29:02 +01:00
parent cb66593b2c
commit 069a37b550
Signed by: Walidoux
GPG Key ID: CCF21881FE8BEBAF

View File

@ -1,9 +1,12 @@
import { createDir, exists, writeTextFile } from '@tauri-apps/api/fs'
import { Convertion } from '../config/Convertion'
export const parseData = async (path: string, fileName: string, fileContent: string | object): Promise<void> => {
const fileDir = path.concat(`/${fileName}.json`)
if (!(await exists(path))) await createDir(path)
if (!(await exists(Convertion.gamedataDir))) await createDir(Convertion.gamedataDir)
if (!(await exists(Convertion.gamedataConfigDir))) await createDir(Convertion.gamedataConfigDir)
await writeTextFile(fileDir, typeof fileContent === 'object' ? JSON.stringify(fileContent) : fileContent)
}