1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-21 01:58:50 +01:00
upscayl/electron/utils/get-resource-paths.ts

25 lines
857 B
TypeScript
Raw Normal View History

2022-11-12 02:09:28 +05:30
import { join, dirname, resolve } from "path";
2023-09-10 14:44:04 +05:30
import { getPlatform } from "./get-device-specs";
2022-11-12 02:09:28 +05:30
import isDev from "electron-is-dev";
import { app } from "electron";
2022-09-25 16:45:43 +05:30
2023-09-11 07:58:33 +05:30
/**
* 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 16:45:43 +05:30
const appRootDir = app.getAppPath();
2022-08-16 07:47:27 +05:30
2022-08-23 19:47:16 +05:30
const binariesPath = isDev
2023-09-05 23:30:33 +05:30
? join(appRootDir, "resources", getPlatform()!, "bin")
2022-09-25 16:45:43 +05:30
: join(dirname(appRootDir), "bin");
2022-08-16 07:47:27 +05:30
const execPath = resolve(join(binariesPath, `./upscayl-bin`));
2022-09-07 08:01:28 +05:30
const modelsPath = isDev
2022-09-25 16:45:43 +05:30
? resolve(join(appRootDir, "resources", "models"))
: resolve(join(dirname(appRootDir), "models"));
2022-08-16 07:47:27 +05:30
2022-11-12 02:09:28 +05:30
export { execPath, modelsPath };