mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
Make userData directory configurable via env (#36)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# Runtime / app
|
# Runtime / app
|
||||||
SCOREKO_APP_TITLE=Scoreko
|
SCOREKO_APP_TITLE=Scoreko
|
||||||
SCOREKO_APP_USER_MODEL_ID=com.scoreko.desktop
|
SCOREKO_APP_USER_MODEL_ID=com.scoreko.desktop
|
||||||
|
SCOREKO_APP_USER_DATA_DIRECTORY=scoreko
|
||||||
# SCOREKO_APP_ICON_PATH=static/icons/icon.ico
|
# SCOREKO_APP_ICON_PATH=static/icons/icon.ico
|
||||||
|
|
||||||
# NodeCG
|
# NodeCG
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export type AppRuntimeConfig = {
|
export type AppRuntimeConfig = {
|
||||||
title: string;
|
title: string;
|
||||||
userModelId: string;
|
userModelId: string;
|
||||||
|
userDataDirectoryName: string;
|
||||||
iconPathOverride?: string;
|
iconPathOverride?: string;
|
||||||
nodecgPort: string;
|
nodecgPort: string;
|
||||||
bundleName: string;
|
bundleName: string;
|
||||||
@@ -19,6 +20,7 @@ export function getRuntimeConfig(): AppRuntimeConfig {
|
|||||||
return {
|
return {
|
||||||
title: getEnv("SCOREKO_APP_TITLE", "Scoreko"),
|
title: getEnv("SCOREKO_APP_TITLE", "Scoreko"),
|
||||||
userModelId: getEnv("SCOREKO_APP_USER_MODEL_ID", "com.scoreko.desktop"),
|
userModelId: getEnv("SCOREKO_APP_USER_MODEL_ID", "com.scoreko.desktop"),
|
||||||
|
userDataDirectoryName: getEnv("SCOREKO_APP_USER_DATA_DIRECTORY", "scoreko"),
|
||||||
iconPathOverride: getOptionalEnv("SCOREKO_APP_ICON_PATH"),
|
iconPathOverride: getOptionalEnv("SCOREKO_APP_ICON_PATH"),
|
||||||
nodecgPort: parseEnvPort("NODECG_PORT", "9090"),
|
nodecgPort: parseEnvPort("NODECG_PORT", "9090"),
|
||||||
bundleName: getEnv("NODECG_BUNDLE_NAME", "scoreko-dev"),
|
bundleName: getEnv("NODECG_BUNDLE_NAME", "scoreko-dev"),
|
||||||
|
|||||||
+4
-2
@@ -9,6 +9,10 @@ import { createLoadingWindow, createMainWindow } from "./windows/window-factory"
|
|||||||
|
|
||||||
const appConfig = getRuntimeConfig();
|
const appConfig = getRuntimeConfig();
|
||||||
|
|
||||||
|
// Force a stable userData folder name; overridable via SCOREKO_APP_USER_DATA_DIRECTORY.
|
||||||
|
app.setName(appConfig.title);
|
||||||
|
app.setPath("userData", path.join(app.getPath("appData"), appConfig.userDataDirectoryName));
|
||||||
|
|
||||||
const isDev = !app.isPackaged;
|
const isDev = !app.isPackaged;
|
||||||
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
|
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
|
||||||
const nodecgRootPath = path.resolve(rootPath, "lib", "nodecg");
|
const nodecgRootPath = path.resolve(rootPath, "lib", "nodecg");
|
||||||
@@ -96,8 +100,6 @@ function stopNodecgGracefully(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.on("ready", () => {
|
app.on("ready", () => {
|
||||||
app.setName(appConfig.title);
|
|
||||||
|
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
app.setAppUserModelId(appConfig.userModelId);
|
app.setAppUserModelId(appConfig.userModelId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ function getBaseConfig(): AppRuntimeConfig {
|
|||||||
return {
|
return {
|
||||||
title: "Scoreko",
|
title: "Scoreko",
|
||||||
userModelId: "com.scoreko.desktop",
|
userModelId: "com.scoreko.desktop",
|
||||||
|
userDataDirectoryName: "scoreko",
|
||||||
nodecgPort: "9090",
|
nodecgPort: "9090",
|
||||||
bundleName: "scoreko-dev",
|
bundleName: "scoreko-dev",
|
||||||
mainDashboardRoute: "dashboard/scoreko-dev/main.html?standalone=true",
|
mainDashboardRoute: "dashboard/scoreko-dev/main.html?standalone=true",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ function getBaseConfig(): AppRuntimeConfig {
|
|||||||
return {
|
return {
|
||||||
title: "Scoreko",
|
title: "Scoreko",
|
||||||
userModelId: "com.scoreko.desktop",
|
userModelId: "com.scoreko.desktop",
|
||||||
|
userDataDirectoryName: "scoreko",
|
||||||
nodecgPort: "9090",
|
nodecgPort: "9090",
|
||||||
bundleName: "scoreko-dev",
|
bundleName: "scoreko-dev",
|
||||||
mainDashboardRoute: "dashboard/scoreko-dev/main.html?standalone=true",
|
mainDashboardRoute: "dashboard/scoreko-dev/main.html?standalone=true",
|
||||||
|
|||||||
Reference in New Issue
Block a user