refactor(server/utils): isDev move to utils and replace fn with boolean

this value cannot change during runtime,
=> there is no need to have these checks
as dynamic function, instead just
export the boolean value directly
This commit is contained in:
Panagiotis Papadopoulos
2025-01-22 19:08:38 +01:00
parent ca2bb94200
commit 31c46753de
9 changed files with 18 additions and 29 deletions

View File

@@ -8,7 +8,6 @@ import sanitize from "sanitize-filename";
import mimeTypes from "mime-types";
import path from "path";
import { fileURLToPath } from "url";
import env from "./env.js";
import { dirname, join } from "path";
const randtoken = generator({ source: "crypto" });
@@ -19,6 +18,8 @@ export const isWindows = process.platform === "win32";
export const isElectron = !!process.versions["electron"];
export const isDev = !!(process.env.TRILIUM_ENV && process.env.TRILIUM_ENV === "dev");
export function newEntityId() {
return randomString(12);
}
@@ -316,7 +317,7 @@ export function envToBoolean(val: string | undefined) {
* @returns the resource dir.
*/
export function getResourceDir() {
if (isElectron && !env.isDev()) {
if (isElectron && !isDev) {
return process.resourcesPath;
} else {
return join(dirname(fileURLToPath(import.meta.url)), "..", "..");