[Utils > u2LoadModulePath] Cleanup source

This commit is contained in:
Ducko 2022-01-29 11:21:05 +00:00
parent 65058550f2
commit 4f7ce2a3d5

View file

@ -5,18 +5,13 @@ const NodeModule = require('module');
const paths = require('../paths');
module.exports = (moduleName) => { // If undefined, load all
module.exports = (moduleName) => {
const modulesDir = join(paths.getExeDir(), 'modules');
const moduleDirs = readdirSync(modulesDir);
if (moduleName) {
const moduleCoreDir = moduleDirs.find((x) => x.startsWith(moduleName + '-')); // Find desktop core dir by name
if (moduleName) return NodeModule.globalPaths.push(join(modulesDir, moduleDirs.find((x) => x.startsWith(moduleName + '-')))); // Specific
return NodeModule.globalPaths.push(join(modulesDir, moduleCoreDir)); // Add to globalPaths for requiring
}
// Undefined moduleName, load all
for (const dir of moduleDirs) {
for (const dir of moduleDirs) { // General (load all)
NodeModule.globalPaths.push(join(modulesDir, dir));
}
};