Move Electron app entrypoint, handle launch errors

This commit is contained in:
Samuel Elliott
2022-09-20 15:50:11 +01:00
parent 13486a89c8
commit fa2854b527
9 changed files with 52 additions and 38 deletions

24
src/common/globals.ts Normal file
View File

@@ -0,0 +1,24 @@
import * as path from 'node:path';
import createDebug from 'debug';
import dotenv from 'dotenv';
import dotenvExpand from 'dotenv-expand';
import { paths } from '../util/storage.js';
let done = false;
export function init() {
if (done) {
throw new Error('Attempted to initialise global data twice');
}
done = true;
dotenvExpand.expand(dotenv.config({
path: path.join(paths.data, '.env'),
}));
if (process.env.NXAPI_DATA_PATH) dotenvExpand.expand(dotenv.config({
path: path.join(process.env.NXAPI_DATA_PATH, '.env'),
}));
if (process.env.DEBUG) createDebug.enable(process.env.DEBUG);
}