OpenAsar/src/index.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

const { join } = require('path');
2022-04-27 18:37:38 +00:00
global.log = (area, ...args) => console.log(`[\x1b[38;2;88;101;242mOpenAsar\x1b[0m > ${area}]`, ...args); // Make log global for easy usage everywhere
global.oaVersion = 'nightly';
2021-12-09 16:25:14 +00:00
2022-02-13 20:52:19 +00:00
log('Init', 'OpenAsar', oaVersion);
if (process.resourcesPath.startsWith('/usr/lib/electron')) global.systemElectron = true; // Using system electron, flag for other places
process.resourcesPath = join(__dirname, '..'); // Force resourcesPath for system electron
const paths = require('./paths');
paths.init();
2021-12-09 16:25:14 +00:00
global.settings = require('./appSettings').getSettings();
global.oaConfig = settings.get('openasar', {});
2021-12-21 10:38:18 +00:00
require('./cmdSwitches')();
2022-04-12 21:42:57 +00:00
// Force u2QuickLoad (pre-"minified" ish)
const M = require('module'); // Module
const b = join(paths.getExeDir(), 'modules'); // Base dir
if (process.platform === 'win32') try {
for (const m of require('fs').readdirSync(b)) M.globalPaths.push(join(b, m)); // For each module dir, add to globalPaths
} catch { log('Init', 'Failed to QS globalPaths') }
if (process.argv.includes('--overlay-host')) { // If overlay
require('./utils/requireNative')('discord_overlay2', 'standalone_host.js'); // Start overlay
} else {
2022-02-13 20:52:19 +00:00
require('./bootstrap')(); // Start bootstrap
}