[Paths] Rewrite to use init to not create each require
This commit is contained in:
parent
615d7b8838
commit
cbe4b5f8a9
|
@ -7,11 +7,9 @@ log('Init', 'OpenAsar', oaVersion);
|
||||||
if (process.resourcesPath.startsWith('/usr/lib/electron')) global.systemElectron = true; // Using system electron, flag for other places
|
if (process.resourcesPath.startsWith('/usr/lib/electron')) global.systemElectron = true; // Using system electron, flag for other places
|
||||||
process.resourcesPath = require('path').join(__dirname, '..'); // Force resourcesPath for system electron
|
process.resourcesPath = require('path').join(__dirname, '..'); // Force resourcesPath for system electron
|
||||||
|
|
||||||
const appSettings = require('./appSettings');
|
require('./paths').init();
|
||||||
global.oaConfig = appSettings.getSettings().get('openasar', {});
|
|
||||||
|
|
||||||
log('Init', 'Loaded config', oaConfig);
|
|
||||||
|
|
||||||
|
global.oaConfig = require('./appSettings').getSettings().get('openasar', {});
|
||||||
require('./cmdSwitches')();
|
require('./cmdSwitches')();
|
||||||
|
|
||||||
if (process.argv.includes('--overlay-host')) { // If overlay
|
if (process.argv.includes('--overlay-host')) { // If overlay
|
||||||
|
|
24
src/paths.js
24
src/paths.js
|
@ -4,16 +4,7 @@ const { app } = require('electron');
|
||||||
|
|
||||||
const buildInfo = require('./utils/buildInfo');
|
const buildInfo = require('./utils/buildInfo');
|
||||||
|
|
||||||
|
let userData, userDataVersioned, resourcesPath, moduleData, exeDir, installPath;
|
||||||
const appDir = 'discord' + (buildInfo.releaseChannel === 'stable' ? '' : buildInfo.releaseChannel); // Clean channel naming up later to util?
|
|
||||||
const userData = join(app.getPath('appData'), appDir);
|
|
||||||
const userDataVersioned = join(userData, buildInfo.version);
|
|
||||||
|
|
||||||
const exeDir = dirname(app.getPath('exe'));
|
|
||||||
const installPath = /^app-[0-9]+\.[0-9]+\.[0-9]+/.test(basename(exeDir)) ? join(exeDir, '..') : null;
|
|
||||||
|
|
||||||
const moduleData = buildInfo.newUpdater ? join(userData, 'module_data') : join(userDataVersioned, 'modules');
|
|
||||||
const resourcesPath = join(process.resourcesPath);
|
|
||||||
|
|
||||||
exports.getUserData = () => userData;
|
exports.getUserData = () => userData;
|
||||||
exports.getUserDataVersioned = () => userDataVersioned;
|
exports.getUserDataVersioned = () => userDataVersioned;
|
||||||
|
@ -24,7 +15,18 @@ exports.getInstallPath = () => installPath;
|
||||||
|
|
||||||
exports.getExeDir = () => exeDir;
|
exports.getExeDir = () => exeDir;
|
||||||
|
|
||||||
exports.init = () => {}; // Stub as we setup on require
|
|
||||||
|
exports.init = () => {
|
||||||
|
const appDir = 'discord' + (buildInfo.releaseChannel === 'stable' ? '' : buildInfo.releaseChannel); // Clean channel naming up later to util?
|
||||||
|
userData = join(app.getPath('appData'), appDir);
|
||||||
|
userDataVersioned = join(userData, buildInfo.version);
|
||||||
|
|
||||||
|
exeDir = dirname(app.getPath('exe'));
|
||||||
|
if (basename(exeDir).startsWith('app-')) installPath = join(exeDir, '..');
|
||||||
|
|
||||||
|
moduleData = buildInfo.newUpdater ? join(userData, 'module_data') : join(userDataVersioned, 'modules');
|
||||||
|
resourcesPath = join(process.resourcesPath);
|
||||||
|
};
|
||||||
|
|
||||||
exports.cleanOldVersions = () => {
|
exports.cleanOldVersions = () => {
|
||||||
if (!installPath) return;
|
if (!installPath) return;
|
||||||
|
|
Loading…
Reference in New Issue