diff --git a/move_enmap.js b/move_enmap.js deleted file mode 100644 index 2e82ad12..00000000 --- a/move_enmap.js +++ /dev/null @@ -1,20 +0,0 @@ -import Enmap from "enmap"; -import { existsSync, readFile, readFileSync,writeFile } from "fs"; - -const pck = JSON.parse(readFileSync("./package.json", "utf8")); - -if (pck.devDependencies.enmap.includes("5")) { - const enmap = new Enmap({ name: "settings" }); - - writeFile("./export.json", enmap.export(), () => { - // I hope the data was in fact saved, because we're deleting it! Double-check your backup file size. - enmap.clear(); - }); -} else if (existsSync("./export.json")) { - const enmap = new Enmap({ name: "settings" }); - readFile("./export.json", (err, data) => { - enmap.import(data); - }); -} else { - console.error("No export file found. Please run the script with the Enmap v5 version first."); -} \ No newline at end of file diff --git a/save_enmap.mjs b/save_enmap.mjs deleted file mode 100644 index 6491cce1..00000000 --- a/save_enmap.mjs +++ /dev/null @@ -1,33 +0,0 @@ -import Enmap from "enmap"; -import { read, readFileSync, writeFile, writeFileSync } from "node:fs"; - -const enmap = new Enmap({ name: "settings" }); - -const mapExport = enmap.export(); - -function isJsonString(str) { - try { - JSON.parse(str); - } catch (e) { - return false; - } - return true; -} - -function deepParse(obj) { - if (typeof obj === 'string' && isJsonString(obj)) { - return deepParse(JSON.parse(obj)); - } if (Array.isArray(obj)) { - return obj.map(deepParse); - } if (obj !== null && typeof obj === 'object') { - for (const [key, value] of Object.entries(obj)) { - obj[key] = deepParse(value); - } - } - return obj; -} - -const data = deepParse(mapExport); -const json = JSON.stringify(data, null, 2); -console.log(json); -writeFileSync("./export.json", json); \ No newline at end of file