From 672fdb2e956f31ac2f4b2bbd2197e2ef5bf8bc07 Mon Sep 17 00:00:00 2001 From: "Kyle J. Kemp" Date: Tue, 1 Oct 2024 15:02:13 -0500 Subject: [PATCH] force using \n for export file --- app/handlers/map.ts | 2 +- app/helpers/index.ts | 1 + app/helpers/json.ts | 5 +++++ app/helpers/modtest.ts | 2 +- app/ipc.ts | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 app/helpers/json.ts diff --git a/app/handlers/map.ts b/app/handlers/map.ts index 9320b1c..5e60110 100644 --- a/app/handlers/map.ts +++ b/app/handlers/map.ts @@ -77,7 +77,7 @@ export function editMap(mapName: string, map: any) { // const map = fs.readJsonSync(path); fixTiledMapPaths(map); - fs.writeJsonSync(path, map); + fs.writeJSONSync(path, map); childProcess.exec(`${baseUrl}/resources/Tiled/tiled.exe "${path}"`); } diff --git a/app/helpers/index.ts b/app/helpers/index.ts index 0fd12df..298022e 100644 --- a/app/helpers/index.ts +++ b/app/helpers/index.ts @@ -1,3 +1,4 @@ export * from './constants'; export * from './dependencies'; +export * from './json'; export * from './modtest'; diff --git a/app/helpers/json.ts b/app/helpers/json.ts new file mode 100644 index 0000000..19316e2 --- /dev/null +++ b/app/helpers/json.ts @@ -0,0 +1,5 @@ +import * as fs from 'fs-extra'; + +export function saveSpecificJSON(path: string, json: any) { + fs.writeJSONSync(path, json, { spaces: 2, EOL: '\n' }); +} diff --git a/app/helpers/modtest.ts b/app/helpers/modtest.ts index 85d93e4..a5145b4 100644 --- a/app/helpers/modtest.ts +++ b/app/helpers/modtest.ts @@ -70,7 +70,7 @@ export function testMod(sendToUI: SendToUI, modData: any) { fs.ensureDirSync(`${baseUrl}/resources/rair/content/mods`); fs.rmdirSync(`${baseUrl}/resources/rair/content/mods`, { recursive: true }); fs.ensureDirSync(`${baseUrl}/resources/rair/content/mods`); - fs.writeJsonSync(`${baseUrl}/resources/rair/content/mods/mod.rairmod`, mod); + fs.writeJSONSync(`${baseUrl}/resources/rair/content/mods/mod.rairmod`, mod); sendToUI('notify', { type: 'info', text: 'Copied mod file!' }); // write .env diff --git a/app/ipc.ts b/app/ipc.ts index 9c210ab..5a1021c 100644 --- a/app/ipc.ts +++ b/app/ipc.ts @@ -223,7 +223,7 @@ export function setupIPC(sendToUI: SendToUI) { try { const fullMod = modData; - fs.writeJSONSync(res, fullMod, { spaces: 2 }); + helpers.saveSpecificJSON(res, fullMod); sendToUI('notify', { type: 'info', text: `Saved ${res}!` }); sendToUI('updatesetting', { setting: 'autosaveFilePath', value: res }); } catch {