1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-12-02 19:17:25 +01:00
upscayl/electron/utils/get-resource-paths.ts

25 lines
871 B
TypeScript
Raw Normal View History

2022-11-11 21:39:28 +01:00
import { join, dirname, resolve } from "path";
2023-09-10 11:14:04 +02:00
import { getPlatform } from "./get-device-specs";
2022-11-11 21:39:28 +01:00
import isDev from "electron-is-dev";
import { app } from "electron";
2022-09-25 13:15:43 +02:00
2023-09-11 04:28:33 +02:00
/**
* appRootDir is the resources directory inside the unpacked electron app temp directory.
* resources contains app.asar file, that contains the main and renderer files.
* We're putting resources/{os}/bin from project inside resources/bin of electron.
* Same for the models directory as well.
*/
2022-09-25 13:15:43 +02:00
const appRootDir = app.getAppPath();
2022-08-16 04:17:27 +02:00
2022-08-23 16:17:16 +02:00
const binariesPath = isDev
2023-09-05 20:00:33 +02:00
? join(appRootDir, "resources", getPlatform()!, "bin")
2022-09-25 13:15:43 +02:00
: join(dirname(appRootDir), "bin");
2022-08-16 04:17:27 +02:00
2023-10-14 03:00:49 +02:00
const execPath = (execName) => resolve(join(binariesPath, `./upscayl-bin`));
2022-09-07 04:31:28 +02:00
const modelsPath = isDev
2022-09-25 13:15:43 +02:00
? resolve(join(appRootDir, "resources", "models"))
: resolve(join(dirname(appRootDir), "models"));
2022-08-16 04:17:27 +02:00
2022-11-11 21:39:28 +01:00
export { execPath, modelsPath };