[Utils > u2LoadModulePath] Cleanup source

main
Oj 2 years ago
parent 65058550f2
commit 4f7ce2a3d5

@ -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));
}
};
Loading…
Cancel
Save