[Paths] Rewrite to use init to not create each require
This commit is contained in:
parent
615d7b8838
commit
cbe4b5f8a9
2 changed files with 15 additions and 15 deletions
|
@ -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
|
||||
process.resourcesPath = require('path').join(__dirname, '..'); // Force resourcesPath for system electron
|
||||
|
||||
const appSettings = require('./appSettings');
|
||||
global.oaConfig = appSettings.getSettings().get('openasar', {});
|
||||
|
||||
log('Init', 'Loaded config', oaConfig);
|
||||
require('./paths').init();
|
||||
|
||||
global.oaConfig = require('./appSettings').getSettings().get('openasar', {});
|
||||
require('./cmdSwitches')();
|
||||
|
||||
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 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);
|
||||
let userData, userDataVersioned, resourcesPath, moduleData, exeDir, installPath;
|
||||
|
||||
exports.getUserData = () => userData;
|
||||
exports.getUserDataVersioned = () => userDataVersioned;
|
||||
|
@ -24,7 +15,18 @@ exports.getInstallPath = () => installPath;
|
|||
|
||||
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 = () => {
|
||||
if (!installPath) return;
|
||||
|
|
Loading…
Reference in a new issue