mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 04:16:17 +01:00 
			
		
		
		
	refactor(server/utils): isElectron - replace fn with boolean
this values 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:
		@@ -13,6 +13,12 @@ import { dirname, join } from "path";
 | 
			
		||||
 | 
			
		||||
const randtoken = generator({ source: "crypto" });
 | 
			
		||||
 | 
			
		||||
export const isMac = process.platform === "darwin";
 | 
			
		||||
 | 
			
		||||
export const isWindows = process.platform === "win32";
 | 
			
		||||
 | 
			
		||||
export const isElectron = !!process.versions["electron"];
 | 
			
		||||
 | 
			
		||||
export function newEntityId() {
 | 
			
		||||
    return randomString(12);
 | 
			
		||||
}
 | 
			
		||||
@@ -58,10 +64,6 @@ export function hmac(secret: any, value: any) {
 | 
			
		||||
    return hmac.digest("base64");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function isElectron() {
 | 
			
		||||
    return !!process.versions["electron"];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function hash(text: string) {
 | 
			
		||||
    text = text.normalize();
 | 
			
		||||
 | 
			
		||||
@@ -128,7 +130,7 @@ export function escapeRegExp(str: string) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function crash() {
 | 
			
		||||
    if (isElectron()) {
 | 
			
		||||
    if (isElectron) {
 | 
			
		||||
        (await import("electron")).app.exit(1);
 | 
			
		||||
    } else {
 | 
			
		||||
        process.exit(1);
 | 
			
		||||
@@ -314,19 +316,13 @@ export function envToBoolean(val: string | undefined) {
 | 
			
		||||
 * @returns the resource dir.
 | 
			
		||||
 */
 | 
			
		||||
export function getResourceDir() {
 | 
			
		||||
    if (isElectron() && !env.isDev()) {
 | 
			
		||||
    if (isElectron && !env.isDev()) {
 | 
			
		||||
        return process.resourcesPath;
 | 
			
		||||
    } else {
 | 
			
		||||
        return join(dirname(fileURLToPath(import.meta.url)), "..", "..");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const isMac = process.platform === "darwin";
 | 
			
		||||
 | 
			
		||||
export const isWindows = process.platform === "win32";
 | 
			
		||||
    return process.platform === "win32";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
    randomSecureToken,
 | 
			
		||||
    randomString,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user