[u2QuickLoad] Rewrite and rename from u2LoadModulePath

This commit is contained in:
Ducko 2022-03-10 08:56:34 +00:00
parent b3614d035f
commit 0c8033616a
4 changed files with 15 additions and 21 deletions

View File

@ -13,7 +13,7 @@ global.oaConfig = require('./appSettings').getSettings().get('openasar', {});
require('./cmdSwitches')();
if (process.argv.includes('--overlay-host')) { // If overlay
require('./utils/u2LoadModulePath')(); // Manually load updater 2 module paths (all modules)
require('./utils/u2QuickLoad'); // Manually load updater 2 module paths (all modules)
require('discord_overlay2/standalone_host.js'); // Start overlay
} else {
require('./bootstrap')(); // Start bootstrap

View File

@ -35,9 +35,7 @@ exports.initSplash = (startMinimized = false) => {
if (process.env.OPENASAR_QUICKSTART || oaConfig.quickstart) setTimeout(() => {
destroySplash();
if (newUpdater != null) { // Manually load desktop_core module path for faster requiring
require('../utils/u2LoadModulePath')();
}
if (newUpdater != null) require('../utils/u2QuickLoad'); // Manually load desktop_core module path for faster requiring
launchMainWindow();

View File

@ -1,17 +0,0 @@
const { readdirSync } = require('fs');
const { join } = require('path');
const NodeModule = require('module');
const paths = require('../paths');
module.exports = (moduleName) => {
const modulesDir = join(paths.getExeDir(), 'modules');
const moduleDirs = readdirSync(modulesDir);
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
for (const dir of moduleDirs) { // General (load all)
NodeModule.globalPaths.push(join(modulesDir, dir));
}
};

13
src/utils/u2QuickLoad.js Normal file
View File

@ -0,0 +1,13 @@
const { readdirSync } = require('fs');
const { join } = require('path');
const Module = require('module');
const paths = require('../paths');
const modulesDir = join(paths.getExeDir(), 'modules');
const moduleDirs = readdirSync(modulesDir);
for (const dir of moduleDirs) { // General (load all)
Module.globalPaths.push(join(modulesDir, dir));
}