[Utils > u2LoadModulePath] Cleanup source
This commit is contained in:
parent
65058550f2
commit
4f7ce2a3d5
1 changed files with 3 additions and 8 deletions
|
@ -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…
Reference in a new issue