Dev: Use Different Settings File
This commit is contained in:
parent
9c47e13a15
commit
f51f53fcc5
1 changed files with 33 additions and 7 deletions
|
|
@ -17,16 +17,15 @@
|
|||
*/
|
||||
|
||||
import { app } from "electron";
|
||||
import { copyFileSync, existsSync, readFileSync, writeFileSync } from "fs";
|
||||
import { join } from "path";
|
||||
|
||||
export const DATA_DIR = process.env.EQUICORD_USER_DATA_DIR ?? process.env.VENCORD_USER_DATA_DIR ?? (
|
||||
const suffix = IS_DEV ? "dev" : "";
|
||||
|
||||
export const DATA_DIR = process.env.EQUICORD_USER_DATA_DIR ?? (
|
||||
process.env.DISCORD_USER_DATA_DIR
|
||||
? IS_VESKTOP
|
||||
? join(process.env.DISCORD_USER_DATA_DIR, "..", "VencordData")
|
||||
: join(process.env.DISCORD_USER_DATA_DIR, "..", "EquicordData")
|
||||
: IS_VESKTOP
|
||||
? join(app.getPath("userData"), "..", "Vencord")
|
||||
: join(app.getPath("userData"), "..", "Equicord")
|
||||
? join(process.env.DISCORD_USER_DATA_DIR, "..", "EquicordData", suffix)
|
||||
: join(app.getPath("userData"), "..", "Equicord", suffix)
|
||||
);
|
||||
|
||||
export const SETTINGS_DIR = join(DATA_DIR, "settings");
|
||||
|
|
@ -34,6 +33,7 @@ export const THEMES_DIR = join(DATA_DIR, "themes");
|
|||
export const QUICKCSS_PATH = join(SETTINGS_DIR, "quickCss.css");
|
||||
export const SETTINGS_FILE = join(SETTINGS_DIR, "settings.json");
|
||||
export const NATIVE_SETTINGS_FILE = join(SETTINGS_DIR, "native-settings.json");
|
||||
export const DEV_MIGRATED = join(SETTINGS_DIR, "migration");
|
||||
export const ALLOWED_PROTOCOLS = [
|
||||
"https:",
|
||||
"http:",
|
||||
|
|
@ -45,3 +45,29 @@ export const ALLOWED_PROTOCOLS = [
|
|||
];
|
||||
|
||||
export const IS_VANILLA = /* @__PURE__ */ process.argv.includes("--vanilla");
|
||||
|
||||
if (IS_DEV) {
|
||||
const prodDir = join(DATA_DIR, "..");
|
||||
const settings = join(prodDir, "settings", "settings.json");
|
||||
const quickCss = join(prodDir, "settings", "quickCss.css");
|
||||
|
||||
let migrated = false;
|
||||
if (existsSync(DEV_MIGRATED)) {
|
||||
const content = readFileSync(DEV_MIGRATED, "utf-8");
|
||||
migrated = content.includes("migrated");
|
||||
}
|
||||
|
||||
if (!migrated) {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
if (existsSync(settings)) copyFileSync(settings, SETTINGS_FILE);
|
||||
if (existsSync(quickCss)) copyFileSync(quickCss, QUICKCSS_PATH);
|
||||
writeFileSync(DEV_MIGRATED, "migrated");
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
} catch (err) {
|
||||
console.error("[Equicord] Failed to copy prod data:", err);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue