import path from 'path'; import {app} from 'electron'; /** * @returns true, when the application is starded in develpoment mode */ export function inDevelopment(): boolean { return process.env.NODE_ENV === 'development'; } /** * Converts an error into a stringified object * @param error * @returns an indented JSON srting */ export function stringifyError(error: Error): string { const {message, stack} = error; return JSON.stringify( { message, stack, }, null, 2, ); } /** * resolves the path of the preload script, based on in which state the application is starded * @returns the path to the preload script */ export function getPreloadPath(): string { const preloadScript = '/dist-electron/preload.cjs'; return path.join(app.getAppPath(), inDevelopment() ? '.' : '..', preloadScript); }