mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-22 10:51:02 +01:00
feat(config): enhance base path logic to use executable directory as fallback
This commit is contained in:
@@ -24,8 +24,9 @@
|
||||
},
|
||||
"tasks": {
|
||||
"dev": "APP_BASE_PATH=./dist/dev deno run -A npm:vite dev",
|
||||
"build": "APP_BASE_PATH=./dist/build deno run -A npm:vite build && deno compile --no-check --allow-net --allow-read --allow-write --allow-env --allow-ffi --allow-run --target x86_64-unknown-linux-gnu --output dist/build/profilarr dist/build/mod.ts",
|
||||
"preview": "PORT=6868 APP_BASE_PATH=./dist/dev ./dist/build/profilarr",
|
||||
"build": "APP_BASE_PATH=./dist/build deno run -A npm:vite build && deno compile --no-check --allow-net --allow-read --allow-write --allow-env --allow-ffi --allow-run --target x86_64-unknown-linux-gnu --output dist/linux/profilarr dist/build/mod.ts",
|
||||
"build:windows": "APP_BASE_PATH=./dist/build deno run -A npm:vite build && deno compile --no-check --allow-net --allow-read --allow-write --allow-env --allow-ffi --allow-run --target x86_64-pc-windows-msvc --output dist/windows/profilarr.exe dist/build/mod.ts",
|
||||
"preview": "PORT=6868 APP_BASE_PATH=./dist/dev ./dist/linux/profilarr",
|
||||
"format": "prettier --write .",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"test": "APP_BASE_PATH=./dist/test deno test src/tests --allow-read --allow-write --allow-env",
|
||||
|
||||
@@ -9,8 +9,16 @@ class Config {
|
||||
constructor() {
|
||||
// Default base path logic:
|
||||
// 1. Check environment variable
|
||||
// 2. Fall back to /app (Docker default)
|
||||
this.basePath = Deno.env.get('APP_BASE_PATH') || '/app';
|
||||
// 2. Fall back to directory containing the executable
|
||||
const envPath = Deno.env.get('APP_BASE_PATH');
|
||||
if (envPath) {
|
||||
this.basePath = envPath;
|
||||
} else {
|
||||
// Use the directory where the executable is located
|
||||
const execPath = Deno.execPath();
|
||||
const lastSlash = Math.max(execPath.lastIndexOf('/'), execPath.lastIndexOf('\\'));
|
||||
this.basePath = lastSlash > 0 ? execPath.substring(0, lastSlash) : '.';
|
||||
}
|
||||
|
||||
// Timezone configuration:
|
||||
// 1. Check TZ environment variable
|
||||
|
||||
Reference in New Issue
Block a user